Index: /extensions/GThumb/functions.inc.php
===================================================================
--- /extensions/GThumb/functions.inc.php	(revision 12731)
+++ /extensions/GThumb/functions.inc.php	(revision 12732)
@@ -41,29 +41,6 @@
   if (empty($data['src']))
   {
-    $cache_dir = GTHUMB_CACHE_DIR.'/';
-    if ($params['size'] == 'small' or $conf['GThumb']['cache_big_thumb'])
-    {
-      $cache_dir = $data['cache_path'];
-    }
-    $file = $cache_dir.'/'.md5($picture['path'].(!empty($picture['md5sum']) ? $picture['md5sum'] : '')).'.'.$picture['tn_ext'];
-
-    if (!is_dir($cache_dir))
-    {
-      mkgetdir($cache_dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
-      if (!is_writable($cache_dir))
-      {
-        die("Give write access (chmod 777) to $cache_dir directory at the root of your Piwigo installation");
-      }
-    }
-
-    $filepath = $picture['path'];
-    if ($data['use_high'])
-    {
-      include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
-      $filepath = file_path_for_type($filepath, 'high');
-    }
-    $img = new pwg_image($filepath);
-    $result = $img->pwg_resize($file, $data['width'], $data['height'], $conf['upload_form_thumb_quality'], false, true, ($params['size'] == 'big'), false);
-    $img->destroy();
+    $result = make_gthumb_image($picture, $data);
+    $file = $result['destination'];
   }
   else
@@ -104,4 +81,37 @@
     'height' => $result['height'],
   );
+}
+
+function make_gthumb_image($picture, $data)
+{
+  global $conf;
+
+  $cache_dir = GTHUMB_CACHE_DIR.'/';
+  if ($data['size'] == 'small' or $conf['GThumb']['cache_big_thumb'])
+  {
+    $cache_dir = $data['cache_path'];
+  }
+  $file = $cache_dir.md5($picture['path'].(!empty($picture['md5sum']) ? $picture['md5sum'] : '')).'.'.$picture['tn_ext'];
+
+  if (!is_dir($cache_dir))
+  {
+    mkgetdir($cache_dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
+    if (!is_writable($cache_dir))
+    {
+      die("Give write access (chmod 777) to $cache_dir directory at the root of your Piwigo installation");
+    }
+  }
+
+  $filepath = $picture['path'];
+  if ($data['use_high'])
+  {
+    include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
+    $filepath = file_path_for_type($filepath, 'high');
+  }
+  $img = new pwg_image($filepath);
+  $result = $img->pwg_resize($file, $data['width'], $data['height'], $conf['upload_form_thumb_quality'], false, true, ($data['size'] == 'big'), false);
+  $img->destroy();
+
+  return $result;
 }
 
Index: /extensions/GThumb/main.inc.php
===================================================================
--- /extensions/GThumb/main.inc.php	(revision 12731)
+++ /extensions/GThumb/main.inc.php	(revision 12732)
@@ -77,7 +77,11 @@
       'height' => $ft['TN_HEIGHT'],
     );
+
     if (empty($small_thumb['src']))
     {
-      $small_thumb['src'] = 'ws.php?method=pwg.images.getGThumbPlusThumbnail&image_id='.$small_thumb['id'].'&return=true';
+      include_once(GTHUMB_PATH.'functions.inc.php');
+      $data = get_gthumb_data($pictures[0]);
+      $result = make_gthumb_image($pictures[0], $data);
+      $small_thumb['src'] = $result['destination'];
     }
 
@@ -91,7 +95,16 @@
       'height' => $data['height'],
     );
-    if (empty($data['src']))
+    if (empty($big_thumb['src']))
     {
-      $big_thumb['src'] = 'ws.php?method=pwg.images.getGThumbPlusThumbnail&image_id='.$ft['ID'].'&size=big&return=true';
+      if ($conf['GThumb']['cache_big_thumb'])
+      {
+        include_once(GTHUMB_PATH.'functions.inc.php');
+        $result = make_gthumb_image($pictures[0], $data);
+        $big_thumb['src'] = $result['destination'];
+      }
+      else
+      {
+        $big_thumb['src'] = 'ws.php?method=pwg.images.getGThumbPlusThumbnail&image_id='.$ft['ID'].'&size=big&return=true';
+      }
     }
 
@@ -177,4 +190,5 @@
   $result['use_high'] = $use_high;
   $result['cache_path'] = GTHUMB_CACHE_DIR.'/'.$new_height.'/';
+  $result['size'] = $size;
 
   return $result;
