[wp-trac] [WordPress Trac] #60480: preg_match() warning in wp_image_add_srcset_and_sizes() when image_meta['file'] is missing (was: Warning: Undefined array key "file" in .../wp-includes/media.php on line 1723)
WordPress Trac
noreply at wordpress.org
Mon May 5 19:27:15 UTC 2025
#60480: preg_match() warning in wp_image_add_srcset_and_sizes() when
image_meta['file'] is missing
--------------------------+------------------------------
Reporter: shanemac10 | Owner: (none)
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: Import | Version: 6.4.3
Severity: major | Resolution:
Keywords: has-patch | Focuses:
--------------------------+------------------------------
Comment (by sabernhardt):
If the `wp_image_add_srcset_and_sizes()` checks for the 'file' array key,
I think it could check at the same time as the 'sizes' array key. (Note: I
have not tested this.)
Either
{{{
// Ensure the image meta exists.
if ( empty( $image_meta['sizes'] ) || empty( $image_meta['file'] )
) {
return $image;
}
}}}
or
{{{
// Ensure the image meta exists.
if ( empty( $image_meta['sizes'] ) || ! isset( $image_meta['file']
) ) {
return $image;
}
}}}
----
I copied @enravo's summary from #63394. Additional tickets that mention
//similar// 'file' key messages include #48710, #55872, and #58535 (not
necessarily using the same function).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60480#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list