Ignore:
Timestamp:
Sep 17, 2011, 11:03:58 PM (13 years ago)
Author:
plg
Message:

feature 2441 added: no need to have the HD to regenerate the websize if the
current websize is bigger than resize settings. When it occurs, we move the
current websize as HD and create the new websize from it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r11962 r12175  
    29632963
    29642964  $query='
    2965 SELECT id, path, tn_ext, has_high
     2965SELECT id, path, tn_ext, has_high, width, height
    29662966  FROM '.IMAGES_TABLE.'
    29672967  WHERE id = '.(int)$params['image_id'].'
     
    29752975
    29762976  $image_path = $image['path'];
     2977
     2978  if (!is_valid_image_extension(get_extension($image_path)))
     2979  {
     2980    return new PwgError(403, "image can't be resized");
     2981  }
     2982 
    29772983  $hd_path = get_high_path($image);
    29782984
    2979   if (empty($image['has_high']) or !file_exists($hd_path) or !is_valid_image_extension(get_extension($image_path)))
    2980   {
    2981     return new PwgError(403, "image can't be resized");
     2985  if (empty($image['has_high']) or !file_exists($hd_path))
     2986  {
     2987    if ($image['width'] > $params['maxwidth'] or $image['height'] > $params['maxheight'])
     2988    {
     2989      $hd_path = file_path_for_type($image_path, 'high');
     2990      $hd_dir = dirname($hd_path);
     2991      prepare_directory($hd_dir);
     2992     
     2993      rename($image_path, $hd_path);
     2994      $hd_infos = pwg_image_infos($hd_path);
     2995
     2996      single_update(
     2997        IMAGES_TABLE,
     2998        array(
     2999          'has_high' => 'true',
     3000          'high_filesize' => $hd_infos['filesize'],
     3001          'high_width' => $hd_infos['width'],
     3002          'high_height' => $hd_infos['height'],
     3003          ),
     3004        array(
     3005          'id' => $image['id']
     3006          )
     3007        );
     3008    }
     3009    else
     3010    {
     3011      return new PwgError(403, "image can't be resized");
     3012    }
    29823013  }
    29833014
Note: See TracChangeset for help on using the changeset viewer.