Initialize instead of using isset(). props nacin. see #13556
git-svn-id: https://develop.svn.wordpress.org/trunk@15003 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3c7a2a3cb8
commit
05e2e9b2c4
|
@ -277,6 +277,7 @@ function wp_constrain_dimensions( $current_width, $current_height, $max_width=0,
|
||||||
return array( $current_width, $current_height );
|
return array( $current_width, $current_height );
|
||||||
|
|
||||||
$width_ratio = $height_ratio = 1.0;
|
$width_ratio = $height_ratio = 1.0;
|
||||||
|
$did_width = $did_height = false;
|
||||||
|
|
||||||
if ( $max_width > 0 && $current_width > 0 && $current_width > $max_width ) {
|
if ( $max_width > 0 && $current_width > 0 && $current_width > $max_width ) {
|
||||||
$width_ratio = $max_width / $current_width;
|
$width_ratio = $max_width / $current_width;
|
||||||
|
@ -305,9 +306,9 @@ function wp_constrain_dimensions( $current_width, $current_height, $max_width=0,
|
||||||
// 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. Contraining to the result of a constraint should yield the original result.
|
// We also have issues with recursive calls resulting in an ever-changing result. Contraining to the result of a constraint should yield the original result.
|
||||||
// Thus we look for dimensions that are one pixel shy of the max value and bump them up
|
// Thus we look for dimensions that are one pixel shy of the max value and bump them up
|
||||||
if ( isset( $did_width ) && $did_width && $w == $max_width - 1 )
|
if ( $did_width && $w == $max_width - 1 )
|
||||||
$w = $max_width; // Round it up
|
$w = $max_width; // Round it up
|
||||||
if ( isset( $did_height ) && $did_height && $h == $max_height - 1 )
|
if ( $did_height && $h == $max_height - 1 )
|
||||||
$h = $max_height; // Round it up
|
$h = $max_height; // Round it up
|
||||||
|
|
||||||
return array( $w, $h );
|
return array( $w, $h );
|
||||||
|
|
Loading…
Reference in New Issue