[wp-trac] [WordPress Trac] #30180: wp_get_attachment_image_src does not return alt or meta
WordPress Trac
noreply at wordpress.org
Sat May 28 17:19:32 UTC 2016
#30180: wp_get_attachment_image_src does not return alt or meta
---------------------------------------+----------------------------
Reporter: joedolson | Owner: joedolson
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 4.6
Component: Media | Version:
Severity: normal | Resolution:
Keywords: needs-testing needs-patch | Focuses: accessibility
---------------------------------------+----------------------------
Comment (by joemcgill):
Replying to [comment:9 joedolson]:
> I think this is a great plan. A few questions come to mind:
>
> Which attributes should we return?
> ...
> I'm inclined to think that it should only be the fields needed for the
`img` element...
Good question. I could see use cases for both, to be honest. A function
that only returns an array of attribute values that can be used in `img`
markup could keep the function lighter, but I could also see cases where
knowing additional metadata (like which sizes are registered in the
database with that image) could be valuable to JS front-ends that are
using the information to do more complex calculations based on the result
of API calls.
However, a more advanced use case might be better addressed by a proper
`WP_Image` API rather than speculating and trying to do too much here, so
a function that returns attributes for the `img` element is probably a
good starting point. With that being the case, I would suggest we name the
function `wp_get_attachment_image_attributes()` (to match the name of the
enclosed filter that would need to be maintained).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30180#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list