Opened 3 years ago
Last modified 7 months ago
#55247 new defect (bug)
SVG logos generate warnings from _wp_get_image_size_from_meta()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | minor | Version: | 5.9 |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
If I set an SVG image as my logo in the customizer, my debug log gets filled with the following notices:
PHP Notice: Trying to access array offset on value of type bool in /{redacted}/wp-includes/media.php on line 1182
Looking at that file, that section refers to the following function:
<?php function _wp_get_image_size_from_meta( $size_name, $image_meta ) { if ( 'full' === $size_name ) { return array( absint( $image_meta['width'] ), absint( $image_meta['height'] ), ); } elseif ( ! empty( $image_meta['sizes'][ $size_name ] ) ) { return array( absint( $image_meta['sizes'][ $size_name ]['width'] ), absint( $image_meta['sizes'][ $size_name ]['height'] ), ); } return false; }
I suspect what's happening here is the function is assuming there will always be a height and width meta, which doesn't exist with SVG file types.
Change History (5)
#2
@
3 years ago
Ah, thanks. No, I'm not using a plugin for that, but a code snippet that filters upload_mimes
and wp_check_filetype_and_ext
. You wouldn't happen to know, off-hand, what filter I should use to set a height/width? I'm guessing wp_update_attachment_metadata
?
Note: See
TracTickets for help on using
tickets.
Since SVG uploads are not allowed by core currently, you're likely using a plugin, right? If so, it's up to the plugin to add a width/height, even if it's just arbitrary values. Otherwise, yes, you'll get all sorts of issues with core because the dimensions are used by core all over the place.
It's possible that can be changed if core ever adds support for SVG uploads, but sadly that's not a thing yet (probably a ticket for it somewhere though).