Changeset 1023

Show
Ignore:
Timestamp:
01/11/07 11:50:58 (2 years ago)
Author:
takayama
Message:

Fixed BugId: 46492

* Changed creation rule of the thumbnail file name.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/wheeljack/php/lib/MTUtil.php

    r854 r1023  
    11861186} 
    11871187 
    1188 function get_thumbnail_file($filename, $width = 0, $height = 0, $scale = 0) { 
     1188function get_thumbnail_file($prefix, $filename, $width = 0, $height = 0, $scale = 0) { 
    11891189    # Get source image information 
    11901190    list($src_w, $src_h, $src_type, $src_attr) = getimagesize($filename); 
     
    12181218        $thumb_w = $src_w * $scale / 100; 
    12191219        $thumb_h = $src_h * $scale / 100; 
    1220     } else
     1220    } elseif ($width > 0 || $heigth > 0)
    12211221        $x = $width; if ($width > 0) $thumb_w; 
    1222         $y = $height; if ($height >= 0) $thumb_h; 
    1223         $pct = $width ? ($x / $thumb_w) : ($y / $thumb_h); 
     1222        $y = $height; if ($height > 0) $thumb_h; 
     1223        $pct = $width > 0 ? ($x / $thumb_w) : ($y / $thumb_h); 
    12241224        $thumb_w = (int)($thumb_w * $pct); 
    12251225        $thumb_h = (int)($thumb_h * $pct); 
    12261226    } 
    12271227 
     1228    # Generate thumbnail file name 
     1229    $hash = ''; 
     1230    $hash_src = "height:$thumb_h;width:$thumb_w"; 
     1231    if (floatval(PHP_VERSION) >= 4.3) { 
     1232        $hash = @sha1($hash_src); 
     1233    } else { 
     1234        if (extension_loaded('mhash')) { 
     1235            $hash = bin2hex(mhash(MHASH_SHA1, $hash_src)); 
     1236        } 
     1237    } 
     1238 
    12281239    # Retrieve thumbnail 
    1229     # Sunset-thumb-thumb-90x120.jpg 
    12301240    $path_parts = pathinfo($filename); 
    12311241    $dirname = $path_parts['dirname']; 
    12321242    list($basename) = split("\.", $path_parts['basename']); 
    1233     $thumb_name = $dirname . "/" . $basename . "-thumb-" 
    1234                 . $thumb_h . "x" . $thumb_w . "." . $path_parts['extension']; 
     1243    $thumb_name = $dirname . "/" . $prefix . "." . $hash . "." . $path_parts['extension']; 
    12351244 
    12361245    if(!file_exists($thumb_name)) { 
  • branches/wheeljack/php/lib/function.MTAssetThumbnailLink.php

    r821 r1023  
    1818        $scale = $args['scale']; 
    1919 
    20     list($thumb, $thumb_w, $thumb_h) = get_thumbnail_file($asset['asset_file_path'], $width, $height,$scale); 
     20    list($thumb, $thumb_w, $thumb_h) = get_thumbnail_file($asset['asset_id'], $asset['asset_file_path'], $width, $height, $scale); 
    2121    if ($thumb != '') { 
    2222        $thumb = basename($thumb); 
  • branches/wheeljack/php/lib/function.MTAssetThumbnailURL.php

    r821 r1023  
    1818        $scale = $args['scale']; 
    1919 
    20     list($thumb) = get_thumbnail_file($asset['asset_file_path'], $width, $height,$scale); 
     20    list($thumb) = get_thumbnail_file($asset['asset_id'], $asset['asset_file_path'], $width, $height, $scale); 
    2121    if ($thumb != '') { 
    2222        $thumb = basename($thumb);