Commit 6371434821 for wordpress.org
commit 6371434821582d2e6ed6ed687f52f0ccb704a6ad
Author: audrasjb <audrasjb@git.wordpress.org>
Date: Mon Apr 22 20:35:10 2024 +0000
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
diff --git a/wp-includes/media.php b/wp-includes/media.php
index 081457c602..3eae7adc31 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -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 ) {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 330822c53c..a2578c0247 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -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.