Merge pull request #30165 from woocommerce/fix/29768
Remove potential for type (and division-by-zero) errors when determining thumbnail sizes.
This commit is contained in:
commit
74dfa0d825
|
@ -976,14 +976,14 @@ function wc_get_image_size( $image_size ) {
|
|||
$size['height'] = '';
|
||||
$size['crop'] = 0;
|
||||
} elseif ( 'custom' === $cropping ) {
|
||||
$width = max( 1, get_option( 'woocommerce_thumbnail_cropping_custom_width', '4' ) );
|
||||
$height = max( 1, get_option( 'woocommerce_thumbnail_cropping_custom_height', '3' ) );
|
||||
$width = max( 1, (float) get_option( 'woocommerce_thumbnail_cropping_custom_width', '4' ) );
|
||||
$height = max( 1, (float) get_option( 'woocommerce_thumbnail_cropping_custom_height', '3' ) );
|
||||
$size['height'] = absint( NumberUtil::round( ( $size['width'] / $width ) * $height ) );
|
||||
$size['crop'] = 1;
|
||||
} else {
|
||||
$cropping_split = explode( ':', $cropping );
|
||||
$width = max( 1, current( $cropping_split ) );
|
||||
$height = max( 1, end( $cropping_split ) );
|
||||
$width = max( 1, (float) current( $cropping_split ) );
|
||||
$height = max( 1, (float) end( $cropping_split ) );
|
||||
$size['height'] = absint( NumberUtil::round( ( $size['width'] / $width ) * $height ) );
|
||||
$size['crop'] = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue