Changeset 12732


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

Double thumbnail is generated without ajax

Location:
extensions/GThumb
Files:
2 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
  • extensions/GThumb/main.inc.php

    r12712 r12732  
    7777      'height' => $ft['TN_HEIGHT'],
    7878    );
     79
    7980    if (empty($small_thumb['src']))
    8081    {
    81       $small_thumb['src'] = 'ws.php?method=pwg.images.getGThumbPlusThumbnail&image_id='.$small_thumb['id'].'&return=true';
     82      include_once(GTHUMB_PATH.'functions.inc.php');
     83      $data = get_gthumb_data($pictures[0]);
     84      $result = make_gthumb_image($pictures[0], $data);
     85      $small_thumb['src'] = $result['destination'];
    8286    }
    8387
     
    9195      'height' => $data['height'],
    9296    );
    93     if (empty($data['src']))
     97    if (empty($big_thumb['src']))
    9498    {
    95       $big_thumb['src'] = 'ws.php?method=pwg.images.getGThumbPlusThumbnail&image_id='.$ft['ID'].'&size=big&return=true';
     99      if ($conf['GThumb']['cache_big_thumb'])
     100      {
     101        include_once(GTHUMB_PATH.'functions.inc.php');
     102        $result = make_gthumb_image($pictures[0], $data);
     103        $big_thumb['src'] = $result['destination'];
     104      }
     105      else
     106      {
     107        $big_thumb['src'] = 'ws.php?method=pwg.images.getGThumbPlusThumbnail&image_id='.$ft['ID'].'&size=big&return=true';
     108      }
    96109    }
    97110
     
    177190  $result['use_high'] = $use_high;
    178191  $result['cache_path'] = GTHUMB_CACHE_DIR.'/'.$new_height.'/';
     192  $result['size'] = $size;
    179193
    180194  return $result;
Note: See TracChangeset for help on using the changeset viewer.