Avoid division by zero

git-svn-id: http://svn.automattic.com/wordpress/trunk@10227 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-12-19 07:04:18 +00:00
parent 8427b2b756
commit 980a3bc810
1 changed files with 2 additions and 2 deletions

View File

@ -231,10 +231,10 @@ function wp_constrain_dimensions( $current_width, $current_height, $max_width=0,
$width_ratio = $height_ratio = 1.0; $width_ratio = $height_ratio = 1.0;
if ( $max_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;
if ( $max_height > 0 && $current_height > $max_height ) if ( $max_height > 0 && $current_height > 0 && $current_height > $max_height )
$height_ratio = $max_height / $current_height; $height_ratio = $max_height / $current_height;
// the smaller ratio is the one we need to fit it to the constraining box // the smaller ratio is the one we need to fit it to the constraining box