Announcement

  •  » Extensions
  •  » GThumb+ - Personal thumbnails

#1 2012-02-29 07:32:50

tree3887
Member
2012-02-29
3

GThumb+ - Personal thumbnails

How do you get the personal thumbnails (added in 2.3.g) to work? I am trying to get higher resolution thumbnails for videos.  I have placed high resolution images with the GT- prefix (GT-name.jpg) in the thumbnail directory and even tried clearing the gthumb+ cache and it continues to show the low resolution thumbnail (thumb_name.jpg).

Thanks.

Offline

 

#2 2012-02-29 23:44:52

P@t
Piwigo Team
Nice
2007-06-13
4098

Re: GThumb+ - Personal thumbnails

Be careful with extension (jpeg is different from jpg or JPG).
Can I have a link to see the problem (in private message if you want)?


P@t

Offline

 

#3 2012-06-03 08:41:32

tree3887
Member
2012-02-29
3

Re: GThumb+ - Personal thumbnails

I believe I have discovered the problem.  In the get_gthumb_data function in the main.inc.php file, you are testing to see if it is an image.  If not, you are returning the thumbnail before your code further down has a chance to check for a GT- image file.

It seems to work by moving the GT section above the part that checks to see if it is an image or not.

current code (lines 135-180 of main.inc.php):

Code:

function get_gthumb_data($picture, $size='small')
{
  global $conf;

  $picture_ext = array('jpg', 'jpeg', 'png', 'gif');

  if (!in_array(strtolower(get_extension($picture['path'])), $picture_ext))
  {
    list($width, $height) = getimagesize(get_thumbnail_path($picture));

    return array(
      'src' => get_thumbnail_url($picture),
      'width' => $width,
      'height' => $height,
    );
  }

  $new_height = $size == 'small' ? $conf['GThumb']['height'] : $conf['GThumb']['height'] * 2 + $conf['GThumb']['margin'];
  $file = GTHUMB_CACHE_DIR.'/'.$new_height.'/'.md5($picture['path'].(!empty($picture['md5sum']) ? $picture['md5sum'] : '')).'.'.$picture['tn_ext'];

  if (file_exists($file))
  {
    list($width, $height) = getimagesize($file);

    return array(
      'src' => embellish_url(get_root_url().$file),
      'width' => $width,
      'height' => $height,
    );
  }

  if ( !empty($picture['tn_ext']) )
  {
    $file = substr_replace(get_filename_wo_extension($picture['path']), '/thumbnail/GT-',strrpos($picture['path'],'/'),1).'.'.$picture['tn_ext'];
    if (file_exists($file))
    {
      list($width, $height) = getimagesize($file);

      return array(
        'src' => embellish_url(get_root_url().$file),
        'width' => $width,
        'height' => $height,
      );
    }
  }

new code:

Code:

function get_gthumb_data($picture, $size='small')
{
  global $conf;

  $picture_ext = array('jpg', 'jpeg', 'png', 'gif');

  if ( !empty($picture['tn_ext']) )
  {
    $file = substr_replace(get_filename_wo_extension($picture['path']), '/thumbnail/GT-',strrpos($picture['path'],'/'),1).'.'.$picture['tn_ext'];
    if (file_exists($file))
    {
      list($width, $height) = getimagesize($file);

      return array(
        'src' => embellish_url(get_root_url().$file),
        'width' => $width,
        'height' => $height,
      );
    }
  }
  
  if (!in_array(strtolower(get_extension($picture['path'])), $picture_ext))
  {
    list($width, $height) = getimagesize(get_thumbnail_path($picture));

    return array(
      'src' => get_thumbnail_url($picture),
      'width' => $width,
      'height' => $height,
    );
  }

  $new_height = $size == 'small' ? $conf['GThumb']['height'] : $conf['GThumb']['height'] * 2 + $conf['GThumb']['margin'];
  $file = GTHUMB_CACHE_DIR.'/'.$new_height.'/'.md5($picture['path'].(!empty($picture['md5sum']) ? $picture['md5sum'] : '')).'.'.$picture['tn_ext'];

  if (file_exists($file))
  {
    list($width, $height) = getimagesize($file);

    return array(
      'src' => embellish_url(get_root_url().$file),
      'width' => $width,
      'height' => $height,
    );
  }

Thanks

Offline

 
  •  » Extensions
  •  » GThumb+ - Personal thumbnails

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact