Make WordPress Core

Changeset 58033


Ignore:
Timestamp:
04/22/2024 08:33:31 PM (9 months ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r58009 r58033  
    21282128        $size_array = wp_image_src_get_dimensions( $image_src, $image_meta, $attachment_id );
    21292129
    2130         if ( $size_array ) {
     2130        if ( $size_array && $size_array[0] && $size_array[1] ) {
    21312131            // If the width is enforced through style (e.g. in an inline image), calculate the dimension attributes.
    21322132            $style_width = preg_match( '/style="width:\s*(\d+)px;"/', $image, $match_width ) ? (int) $match_width[1] : 0;
Note: See TracChangeset for help on using the changeset viewer.