wordpress-develop
wordpress-develop copied to clipboard
Fix: Undefined Array Key in `wp_image_add_srcset_and_sizes` function
Trac Ticket: Core-60480
Description
- This pull request addresses a warning encountered during the media import process when using the "Download and import file attachments" option in the Tools > Import section of WordPress. A warning is triggered due to an attempt to access an undefined array key in the
wp_image_add_srcset_and_sizesfunction.
Proposed Changes
-
Added an
isset()check before accessing the 'file' key of the$image_metaarray to prevent the warning from occurring. -
This adjustment ensures that the code handles cases where media metadata retrieval fails more gracefully, avoiding the warning message.
-
Additionally, this change is aimed at bringing consistency across all functions that interact with attachment metadata, ensuring that similar checks are uniformly applied throughout the codebase.