diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php index 9d717d7ea4..72e9037d1d 100644 --- a/wp-admin/includes/image-edit.php +++ b/wp-admin/includes/image-edit.php @@ -467,8 +467,8 @@ function stream_preview_image( $post_id ) { $h = $size['height']; $ratio = _image_get_preview_ratio( $w, $h ); - $w2 = $w * $ratio; - $h2 = $h * $ratio; + $w2 = max ( 1, $w * $ratio ); + $h2 = max ( 1, $h * $ratio ); if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) return false; diff --git a/wp-includes/media.php b/wp-includes/media.php index 5598a5a3f5..8e150a597c 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -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. $ratio = $larger_ratio; - $w = intval( $current_width * $ratio ); - $h = intval( $current_height * $ratio ); + // Very small dimensions may result in 0, 1 should be the minimum. + $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 // 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.