Media: avoid "divide by zero" in `wp_get_attachment_image_srcset_array()`.
Fixes #34238. git-svn-id: https://develop.svn.wordpress.org/trunk@35081 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6e6d9f9830
commit
e05891a7ec
|
@ -921,7 +921,11 @@ function wp_get_attachment_image_srcset_array( $attachment_id, $size = 'medium'
|
||||||
$candidate_url = path_join( dirname( $img_url ), $img['file'] );
|
$candidate_url = path_join( dirname( $img_url ), $img['file'] );
|
||||||
|
|
||||||
// Calculate the new image ratio.
|
// Calculate the new image ratio.
|
||||||
|
if ( $img['width'] ) {
|
||||||
$img_ratio_compare = $img['height'] / $img['width'];
|
$img_ratio_compare = $img['height'] / $img['width'];
|
||||||
|
} else {
|
||||||
|
$img_ratio_compare = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// If the new ratio differs by less than 0.01, use it.
|
// If the new ratio differs by less than 0.01, use it.
|
||||||
if ( abs( $img_ratio - $img_ratio_compare ) < 0.01 && ! in_array( $candidate_url, $candidates ) ) {
|
if ( abs( $img_ratio - $img_ratio_compare ) < 0.01 && ! in_array( $candidate_url, $candidates ) ) {
|
||||||
|
|
Loading…
Reference in New Issue