Opened 7 months ago
Last modified 7 months ago
#57813 new defect (bug)
wp_get_missing_image_subsizes() can give error if image_meta exists, but not height/width
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.1.1 |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
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'] ) ) {
Attachments (1)
Change History (2)
Note: See
TracTickets for help on using
tickets.
patch to wp-admin/includes/image.php