[wp-trac] [WordPress Trac] #27399: Filter the HTML output of wp_get_attachment_image

WordPress Trac noreply at wordpress.org
Fri Sep 29 13:42:31 UTC 2017


#27399: Filter the HTML output of wp_get_attachment_image
-------------------------+------------------------------
 Reporter:  fgirardey    |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Media        |     Version:  3.8.1
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:
-------------------------+------------------------------

Comment (by glueckpress):

 Replying to [comment:15 joemcgill]:
 > I still think adding an additional filter on the built HTML here is
 unnecessary and could lead to more problems than it solves, since this is
 the function used throughout the admin for displaying images. It seems to
 me that if you're trying to use `wp_get_attachment_image` for anything
 other than outputting an `img` element based on an attachment ID and size,
 then you're using the wrong tool.

 That’s exactly what people do. And then they hear about performance,
 activate a plugin to lazy-load their images, and notice that images
 rendered via `wp_get_attachment_image` are not lazy-loaded.

 Why? Because plugins can’t hook into the function as they can with
 [https://github.com/wp-media/rocket-lazy-load other functions] in order to
 append the required `<noscript>` tag to the image HTML output.

 The patch proposed here would solve the dilemma perfectly fine. Fwiw, I
 don’t see why further abstraction would be necessary? It’s a simple
 filter. It would enable plugin developers to solve a common problem. It
 would really help, and it seems to be low hanging fruit, doesn’t it?

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


More information about the wp-trac mailing list