diff --git a/includes/flickrgallery.pages.inc b/includes/flickrgallery.pages.inc
index 1c88056..d7d9d3c 100644
--- a/includes/flickrgallery.pages.inc
+++ b/includes/flickrgallery.pages.inc
@@ -156,14 +156,15 @@ function flickrgallery_set($set_id) {
   $image_meta = array();
 
   foreach ($photos['photoset']['photo'] as $photo) {
+    $original_photo = $f->buildPhotoURL($photo, variable_get('flickrgallery_large', 'large'));
     if (variable_get('flickrgallery_display_type') == 1 && module_exists('image') && module_exists('imagecache_external')) {
       $img = array(
         '#theme' => 'imagecache_external',
         '#style_name' => variable_get('flickrgallery_thumb_imagestyle', 'large'),
-        '#path' => $f->buildPhotoURL($photo, 'large'),
+        '#path' => $original_photo,
       );
 
-      $url_external = imagecache_external_generate_path($original, variable_get('flickrgallery_large_imagestyle', 'large'));
+      $url_external = imagecache_external_generate_path($original_photo, variable_get('flickrgallery_large_imagestyle', 'large'));
       $url = image_style_url(variable_get('flickrgallery_large_imagestyle', 'large'), $url_external);
     }
     else {
@@ -172,7 +173,7 @@ function flickrgallery_set($set_id) {
         '#path' => $f->buildPhotoURL($photo, variable_get('flickrgallery_thumb', 'square')),
       );
 
-      $url = $f->buildPhotoURL($photo, variable_get('flickrgallery_large', 'large'));
+      $url = $original_photo;
     }
 
     // Add default attributes
