Ticket #18532: 18532.2.patch
File 18532.2.patch, 1.5 KB (added by SergeyBiryukov, 3 years ago) 


wpincludes/media.php
294 294 $smaller_ratio = min( $width_ratio, $height_ratio ); 295 295 $larger_ratio = max( $width_ratio, $height_ratio ); 296 296 297 if ( intval( $current_width * $larger_ratio ) > $max_width  intval( $current_height * $larger_ratio ) > $max_height )297 if ( round( $current_width * $larger_ratio ) > $max_width  round( $current_height * $larger_ratio ) > $max_height ) 298 298 // The larger ratio is too big. It would result in an overflow. 299 299 $ratio = $smaller_ratio; 300 300 else 301 301 // The larger ratio fits, and is likely to be a more "snug" fit. 302 302 $ratio = $larger_ratio; 303 303 304 $w = intval( $current_width * $ratio );305 $h = intval( $current_height * $ratio );304 $w = round( $current_width * $ratio ); 305 $h = round( $current_height * $ratio ); 306 306 307 307 // Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short 308 308 // We also have issues with recursive calls resulting in an everchanging result. Contraining to the result of a constraint should yield the original result. … … 312 312 if ( $did_height && $h == $max_height  1 ) 313 313 $h = $max_height; // Round it up 314 314 315 return a rray( $w, $h);315 return apply_filters( 'wp_constrain_dimensions', array( $w, $h ), $current_width, $current_height, $max_width, $max_height ); 316 316 } 317 317 318 318 /**