Changes in trunk/wp-includes/media.php [12153:12280]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/media.php
r12153 r12280 260 260 * @return bool|array False, on failure. Returned array matches parameters for imagecopyresampled() PHP function. 261 261 */ 262 function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop =false) {262 function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = false) { 263 263 264 264 if ($orig_w <= 0 || $orig_h <= 0) … … 273 273 $new_w = min($dest_w, $orig_w); 274 274 $new_h = min($dest_h, $orig_h); 275 if (!$new_w) { 275 276 if ( !$new_w ) { 276 277 $new_w = intval($new_h * $aspect_ratio); 277 278 } 278 if (!$new_h) { 279 280 if ( !$new_h ) { 279 281 $new_h = intval($new_w / $aspect_ratio); 280 282 } … … 282 284 $size_ratio = max($new_w / $orig_w, $new_h / $orig_h); 283 285 284 $crop_w = ceil($new_w / $size_ratio); 285 $crop_h = ceil($new_h / $size_ratio); 286 287 $s_x = floor(($orig_w - $crop_w)/2); 288 $s_y = floor(($orig_h - $crop_h)/2); 289 } 290 else { 286 $crop_w = round($new_w / $size_ratio); 287 $crop_h = round($new_h / $size_ratio); 288 289 $s_x = floor( ($orig_w - $crop_w) / 2 ); 290 $s_y = floor( ($orig_h - $crop_h) / 2 ); 291 } else { 291 292 // don't crop, just resize using $dest_w x $dest_h as a maximum bounding box 292 293 $crop_w = $orig_w; … … 300 301 301 302 // if the resulting image would be the same size or larger we don't want to resize it 302 if ( $new_w >= $orig_w && $new_h >= $orig_h)303 if ( $new_w >= $orig_w && $new_h >= $orig_h ) 303 304 return false; 304 305 305 306 // the return array matches the parameters to imagecopyresampled() 306 307 // int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h 307 return array( 0, 0, $s_x, $s_y, $new_w, $new_h, $crop_w, $crop_h);308 return array( 0, 0, $s_x, $s_y, $new_w, $new_h, $crop_w, $crop_h ); 308 309 309 310 }
Note: See TracChangeset
for help on using the changeset viewer.