[wp-trac] [WordPress Trac] #64417: Check to see height and width exist in wp_get_missing_image_subsizes
WordPress Trac
noreply at wordpress.org
Mon Dec 15 15:14:48 UTC 2025
#64417: Check to see height and width exist in wp_get_missing_image_subsizes
--------------------------+-----------------------------
Reporter: spacedmonkey | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 6.0
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
In wp-admin/includes/image.php, the function
wp_get_missing_image_subsizes() triggers "Undefined array key" warnings
for width and height when processing image metadata that lacks dimension
data but contains other keys.
The function attempts to retrieve dimensions using the following code:
{{{#!php
$full_width = (int) $image_meta['width'];
$full_height = (int) $image_meta['height'];
}}}
There is an initial check at the top of the function: `if ( empty(
$image_meta ) )`. However, this check is insufficient because $image_meta
can be a non-empty array that still lacks dimensions. This appears to be a
regression related to #49412, which modified
wp_generate_attachment_metadata to include a filesize key. Consequently,
if metadata generation partially fails or if only the filesize is stored,
$image_meta is not empty, causing the code to fall through to the
dimension assignment and throw PHP warnings.
To fix this, the guard clause should be updated to explicitly check for
the existence of the required dimension keys, rather than relying solely
on empty().
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64417>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list