[wp-trac] [WordPress Trac] #37549: Add optional parameter to wp_generate_attachment_metadata for image dimensions.
WordPress Trac
noreply at wordpress.org
Wed Aug 3 03:16:18 UTC 2016
#37549: Add optional parameter to wp_generate_attachment_metadata for image
dimensions.
-------------------------+------------------------------
Reporter: sterlo | Owner: joemcgill
Type: enhancement | Status: reviewing
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------+------------------------------
Changes (by joemcgill):
* owner: => joemcgill
* status: new => reviewing
Comment:
Hi @sterlo,
Thanks for the detailed description and initial patch. I think you might
be able to accomplish what you need to with a filter on the output of
`wp_generate_attachment_metadata()`. In reality, you don't want to jump
into the first branch of that `if` statement, because the only metadata
you need is the height, width, and file—not the additional intermediate
sizes.
Could you get the `attachment_id` from the filter, see if the attachment
is an SVG, and then generate those three pieces of data (most of which you
demonstrated in your gist)? This would also avoid the `getimagesize()`
issues you run into in `file_is_displayable_image()` as well.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37549#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list