Opened 13 years ago
Closed 13 years ago
#22438 closed defect (bug) (fixed)
wp_generate_attachment_metadata() should not call WP_Image_Editor if there's nothing to resize
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.5 | Priority: | normal |
| Severity: | normal | Version: | 3.5 |
| Component: | Media | Keywords: | has-patch |
| Focuses: | Cc: |
Description
wp_generate_attachment_metadata() calls WP_Image_Editor::multi_resize() to create the intermediate sizes of the image.
If there are no sizes to create, WP_Image_Editor::get_instance() should not be called. It will not be used for anything and is a waste of resources.
If it is called, and the image is very large, a needless Out of Memory Fatal Error can result.
Patch attached.
Attachments (1)
Change History (4)
Note: See
TracTickets for help on using
tickets.
I put in the else condition to set
$metadata['sizes'] = array()since that's what the current behavior in trunk is:::multi_resize()returns an empty array if$sizesis empty.In 3.4,
$metadata['sizes']would have been left unset.