Media: Prevent division by zero in `wp_img_tag_add_width_and_height_attr()`.

This changesets adds a check for `$size_array` values to prevent a potential division by zero.
Follow-up to [57294].

Props jdekhtiar.
Fixes #61054.
See #59352.



Built from https://develop.svn.wordpress.org/trunk@58033


git-svn-id: http://core.svn.wordpress.org/trunk@57499 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2024-04-22 20:35:10 +00:00
parent 2d2b97f115
commit 6371434821
2 changed files with 2 additions and 2 deletions

View File

@ -2127,7 +2127,7 @@ function wp_img_tag_add_width_and_height_attr( $image, $context, $attachment_id
$image_meta = wp_get_attachment_metadata( $attachment_id );
$size_array = wp_image_src_get_dimensions( $image_src, $image_meta, $attachment_id );
if ( $size_array ) {
if ( $size_array && $size_array[0] && $size_array[1] ) {
// If the width is enforced through style (e.g. in an inline image), calculate the dimension attributes.
$style_width = preg_match( '/style="width:\s*(\d+)px;"/', $image, $match_width ) ? (int) $match_width[1] : 0;
if ( $style_width ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-58032';
$wp_version = '6.6-alpha-58033';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.