Make sure when resizing an image according to ratio we do not end up with a zero-pixel width or height.
props plocha. fixes #25038. Built from https://develop.svn.wordpress.org/trunk@25744 git-svn-id: http://core.svn.wordpress.org/trunk@25657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
66be5edfb5
commit
f0eb99952c
|
@ -467,8 +467,8 @@ function stream_preview_image( $post_id ) {
|
||||||
$h = $size['height'];
|
$h = $size['height'];
|
||||||
|
|
||||||
$ratio = _image_get_preview_ratio( $w, $h );
|
$ratio = _image_get_preview_ratio( $w, $h );
|
||||||
$w2 = $w * $ratio;
|
$w2 = max ( 1, $w * $ratio );
|
||||||
$h2 = $h * $ratio;
|
$h2 = max ( 1, $h * $ratio );
|
||||||
|
|
||||||
if ( is_wp_error( $img->resize( $w2, $h2 ) ) )
|
if ( is_wp_error( $img->resize( $w2, $h2 ) ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -284,8 +284,9 @@ function wp_constrain_dimensions( $current_width, $current_height, $max_width=0,
|
||||||
// The larger ratio fits, and is likely to be a more "snug" fit.
|
// The larger ratio fits, and is likely to be a more "snug" fit.
|
||||||
$ratio = $larger_ratio;
|
$ratio = $larger_ratio;
|
||||||
|
|
||||||
$w = intval( $current_width * $ratio );
|
// Very small dimensions may result in 0, 1 should be the minimum.
|
||||||
$h = intval( $current_height * $ratio );
|
$w = max ( 1, intval( $current_width * $ratio ) );
|
||||||
|
$h = max ( 1, intval( $current_height * $ratio ) );
|
||||||
|
|
||||||
// Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short
|
// Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short
|
||||||
// We also have issues with recursive calls resulting in an ever-changing result. Constraining to the result of a constraint should yield the original result.
|
// We also have issues with recursive calls resulting in an ever-changing result. Constraining to the result of a constraint should yield the original result.
|
||||||
|
|
Loading…
Reference in New Issue