diff --git a/field_slideshow.module b/field_slideshow.module
index a9a2240..b34a014 100644
--- a/field_slideshow.module
+++ b/field_slideshow.module
@@ -591,14 +591,14 @@ function field_slideshow_field_formatter_view($entity_type, $entity, $field, $in
     'slideshow_link'          => 'path',
     'slideshow_caption_link'  => 'caption_path',
   );
-  // Loop thru required links (because image and caption can have different links)
+  // Loop through required links (because image and caption can have different links).
   foreach ($links as $setting => $path) {
-
+    $uri = array();
+    
     // Check if the formatter involves a link.
     $link_type = '';
     switch ($settings[$setting]) {
       case 'content':
-        $content_uri = entity_uri($entity_type, $entity);
         $link_type = 'content';
       break;
       case 'file':
@@ -613,15 +613,11 @@ function field_slideshow_field_formatter_view($entity_type, $entity, $field, $in
       break;
     }
 
-    // Get the correct field for identifying entity (used to get correct links)
-    $entity_info = entity_get_info($entity_type);
-    $entity_id_field = $entity_info['entity keys']['id'];
     // Generate special links (other than node)
     foreach ($items as $delta => $item) {
-      $uri = array();
       switch ($link_type) {
         case 'content':
-          $uri = $content_uri;
+          $uri = entity_uri($entity_type, $entity);
         break;
         case 'file':
           $uri = array(
@@ -633,6 +629,9 @@ function field_slideshow_field_formatter_view($entity_type, $entity, $field, $in
             if ($settings['slideshow_colorbox_image_style'] != '') {
               $uri['path'] = image_style_url($settings['slideshow_colorbox_image_style'], $item['uri']);
             }
+            // Get the correct field for identifying entity (used to get correct links)
+            $entity_info = entity_get_info($entity_type);
+            $entity_id_field = $entity_info['entity keys']['id'];
             // add correct attributes
             $uri['options']['attributes'] = array(
               'class' => array('colorbox'),
@@ -666,9 +665,8 @@ function field_slideshow_field_formatter_view($entity_type, $entity, $field, $in
           }
         break;
       }
-      $items[$delta][$path] = isset($uri) ? $uri : '';
+      $items[$delta][$path] = !empty($uri) ? $uri : '';
     }
-    unset($uri, $link_type); // unset for next loop;
   }
 
   if (count($items)) {
