[wp-trac] [WordPress Trac] #57813: wp_get_missing_image_subsizes() can give error if image_meta exists, but not height/width

WordPress Trac noreply at wordpress.org
Sun Feb 26 21:47:16 UTC 2023


#57813: wp_get_missing_image_subsizes() can give error if image_meta exists, but
not height/width
--------------------------+-----------------------------
 Reporter:  donbowman     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  6.1.1
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 I have an SVG file attached as image. The function throws an error:

 {{{
         if ( ! empty( $imagesize ) ) {
                 $full_width  = $imagesize[0];
                 $full_height = $imagesize[1];
         } else {
                 $full_width  = (int) $image_meta['width'];
                 $full_height = (int) $image_meta['height'];
         }
 }}}

 on the else case. The below patch will resolve.
 This is with 6.1.1

 {{{
 --- /app/wp-admin/includes/image.php.orig       2023-02-26
 21:42:57.687046116 +0000
 +++ /app/wp-admin/includes/image.php    2023-02-26 21:40:41.349180739
 +0000
 @@ -89,11 +89,11 @@

         $registered_sizes = wp_get_registered_image_subsizes();
         $image_meta       = wp_get_attachment_metadata( $attachment_id );

         // Meta error?
 -       if ( empty( $image_meta ) ) {
 +       if ( empty( $image_meta ) || !array_key_exists('width',
 $image_meta) || !array_key_exists('height', $image_meta) ) {
                 return $registered_sizes;
         }

         // Use the originally uploaded image dimensions as full_width and
 full_height.
         if ( ! empty( $image_meta['original_image'] ) ) {
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57813>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list