Ignore:
Timestamp:
Dec 14, 2011, 1:32:52 PM (12 years ago)
Author:
patdenice
Message:

Double thumbnail is generated without ajax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GThumb/functions.inc.php

    r12705 r12732  
    4141  if (empty($data['src']))
    4242  {
    43     $cache_dir = GTHUMB_CACHE_DIR.'/';
    44     if ($params['size'] == 'small' or $conf['GThumb']['cache_big_thumb'])
    45     {
    46       $cache_dir = $data['cache_path'];
    47     }
    48     $file = $cache_dir.'/'.md5($picture['path'].(!empty($picture['md5sum']) ? $picture['md5sum'] : '')).'.'.$picture['tn_ext'];
    49 
    50     if (!is_dir($cache_dir))
    51     {
    52       mkgetdir($cache_dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
    53       if (!is_writable($cache_dir))
    54       {
    55         die("Give write access (chmod 777) to $cache_dir directory at the root of your Piwigo installation");
    56       }
    57     }
    58 
    59     $filepath = $picture['path'];
    60     if ($data['use_high'])
    61     {
    62       include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
    63       $filepath = file_path_for_type($filepath, 'high');
    64     }
    65     $img = new pwg_image($filepath);
    66     $result = $img->pwg_resize($file, $data['width'], $data['height'], $conf['upload_form_thumb_quality'], false, true, ($params['size'] == 'big'), false);
    67     $img->destroy();
     43    $result = make_gthumb_image($picture, $data);
     44    $file = $result['destination'];
    6845  }
    6946  else
     
    10481    'height' => $result['height'],
    10582  );
     83}
     84
     85function make_gthumb_image($picture, $data)
     86{
     87  global $conf;
     88
     89  $cache_dir = GTHUMB_CACHE_DIR.'/';
     90  if ($data['size'] == 'small' or $conf['GThumb']['cache_big_thumb'])
     91  {
     92    $cache_dir = $data['cache_path'];
     93  }
     94  $file = $cache_dir.md5($picture['path'].(!empty($picture['md5sum']) ? $picture['md5sum'] : '')).'.'.$picture['tn_ext'];
     95
     96  if (!is_dir($cache_dir))
     97  {
     98    mkgetdir($cache_dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
     99    if (!is_writable($cache_dir))
     100    {
     101      die("Give write access (chmod 777) to $cache_dir directory at the root of your Piwigo installation");
     102    }
     103  }
     104
     105  $filepath = $picture['path'];
     106  if ($data['use_high'])
     107  {
     108    include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
     109    $filepath = file_path_for_type($filepath, 'high');
     110  }
     111  $img = new pwg_image($filepath);
     112  $result = $img->pwg_resize($file, $data['width'], $data['height'], $conf['upload_form_thumb_quality'], false, true, ($data['size'] == 'big'), false);
     113  $img->destroy();
     114
     115  return $result;
    106116}
    107117
Note: See TracChangeset for help on using the changeset viewer.