Changeset 1023
- Timestamp:
- 01/11/07 11:50:58 (2 years ago)
- Files:
-
- branches/wheeljack/php/lib/MTUtil.php (modified) (2 diffs)
- branches/wheeljack/php/lib/function.MTAssetThumbnailLink.php (modified) (1 diff)
- branches/wheeljack/php/lib/function.MTAssetThumbnailURL.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/wheeljack/php/lib/MTUtil.php
r854 r1023 1186 1186 } 1187 1187 1188 function get_thumbnail_file($ filename, $width = 0, $height = 0, $scale = 0) {1188 function get_thumbnail_file($prefix, $filename, $width = 0, $height = 0, $scale = 0) { 1189 1189 # Get source image information 1190 1190 list($src_w, $src_h, $src_type, $src_attr) = getimagesize($filename); … … 1218 1218 $thumb_w = $src_w * $scale / 100; 1219 1219 $thumb_h = $src_h * $scale / 100; 1220 } else {1220 } elseif ($width > 0 || $heigth > 0) { 1221 1221 $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); 1224 1224 $thumb_w = (int)($thumb_w * $pct); 1225 1225 $thumb_h = (int)($thumb_h * $pct); 1226 1226 } 1227 1227 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 1228 1239 # Retrieve thumbnail 1229 # Sunset-thumb-thumb-90x120.jpg1230 1240 $path_parts = pathinfo($filename); 1231 1241 $dirname = $path_parts['dirname']; 1232 1242 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']; 1235 1244 1236 1245 if(!file_exists($thumb_name)) { branches/wheeljack/php/lib/function.MTAssetThumbnailLink.php
r821 r1023 18 18 $scale = $args['scale']; 19 19 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); 21 21 if ($thumb != '') { 22 22 $thumb = basename($thumb); branches/wheeljack/php/lib/function.MTAssetThumbnailURL.php
r821 r1023 18 18 $scale = $args['scale']; 19 19 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); 21 21 if ($thumb != '') { 22 22 $thumb = basename($thumb);
