[wp-trac] [WordPress Trac] #30180: wp_get_attachment_image_src does not return alt or meta

WordPress Trac noreply at wordpress.org
Thu Sep 19 16:39:52 UTC 2019


#30180: wp_get_attachment_image_src does not return alt or meta
----------------------------+-----------------------------
 Reporter:  joedolson       |       Owner:  antpb
     Type:  defect (bug)    |      Status:  assigned
 Priority:  normal          |   Milestone:  Future Release
Component:  Media           |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  needs-dev-note  |     Focuses:  accessibility
----------------------------+-----------------------------
Changes (by azaozz):

 * keywords:  has-patch has-unit-tests dev-feedback needs-dev-note => needs-
     dev-note
 * milestone:  5.3 => Future Release


Comment:

 Frankly I tend to agree with @antpb here. Looking at the new
 `wp_get_attachment_image_attr()` it tries to "do everything for everybody"
 and introduces strange/inconsistent behaviour and lots of complexity.

 The new function is just a helper function to do several things that can
 be done in few other ways. It is "nice to have", but it should at least be
 easy to use/understand, and ...helpful :)

 After a quick look, thinking that `wp_get_attachment_image_attr()` should
 be simplified significantly. It should return all available image
 attachment attributes, and should not support passing an array of
 unidentified parameters. That just adds lots of complexity and makes the
 function harder to use, especially if that array is changed in the future.

 We definitely don't want to end up with "monstrous", inconsistent, weird
 behaviour stuff like the misused `image_constrain_size_for_editor()` which
 should never be used outside the classic editor context.

 Thinking that to make this new function useful it will need to be changed:
 - Remove the `$attribute` param. Doesn't make sense to limit it. Seems
 that all needed data would be cached by that time.
 - Remove the `$args` param. "Unidentified" parameters are never a good
 idea imho.
 - Remove the second/duplicate filter with dynamic name. Dynamically named
 filters are always a bad idea and it is not needed.

 To make it possible to limit it to a particular sub-size (which is not a
 good idea, but may make sense in some contexts), a `$size` array with max
 `width` and `height` might be useful, but needs more thinking/testing.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/30180#comment:67>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list