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

WordPress Trac noreply at wordpress.org
Fri Sep 20 17:06:42 UTC 2019


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

Comment (by azaozz):

 Replying to [comment:72 afercia]:
 > Looking at the history of this ticket, following the chronological order
 of events, it's clear it didn't receive much attention. It was punted
 several times ''skipping at least 4 entire release cycles''.

 I think I can answer this :)

 This ticket is a minor enhancement that makes sense on some level but is
 also somewhat "questionable". It doesn't bring anything new, just repeats
 existing code/features and tries to make them a bit more convenient to
 use, but at the same time has some drawbacks.

 Imho this is the reason it went through several iterations and is still
 not ready. It doesn't bring anything of significant value. Looking at the
 ticket itself:

 > In practical use, wp_get_attachment_image_src is very useful for
 displaying an attached image - but requires a separate call to get any
 other image meta or the alt attribute.

 That's right. `wp_get_attachment_image_src()` is a function to retrieve
 the `src` of an image. Nothing more. Similarly other attachment data can
 be retrieved by other functions. This works quite well.

 Having a helper/convenience function to combine all of the attachment data
 that may be needed when outputting an `<img>` tag is not a bad idea, but
 it repeats existing functionality that already is straightforward and easy
 to use.

 As @joemcgill and I mention above the current implementation is "not there
 yet". It should probably be a refactoring of `wp_get_attachment_image()`.
 The functionality proposed in this ticket seems to belong there. And yes,
 it may take a long time to come up with the right solution/code,
 especially when the proposed change is "on the fence" and doesn't bring
 new features or significant improvements.

 There is also the chance that automatically adding `alt` text that is
 stored in the DB to all `<img>` tags will introduce errors. Images can be
 used in different contexts, always having the same `alt` regardless of
 context may be wrong in some cases. But that's for the accessibility team
 to decide, just trying to think what else may be needed in the
 implementation :)

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


More information about the wp-trac mailing list