WordPress.org

Make WordPress Core

Opened 12 days ago

Last modified 7 days ago

#50801 new enhancement

A filter for wp_get_attachment_image() html output

Reported by: prionkor Owned by:
Milestone: 5.6 Priority: normal
Severity: normal Version: 5.4.2
Component: Media Keywords: has-patch dev-feedback has-unit-tests
Focuses: Cc:

Description

The function wp_get_attachment_image() is used to output image tags in WP sites. Currently it has a filter for attr but not filter on html output of the function. I am proposing a filter so plugin developers can modify its output.

An example use case:

Output of <picture> tag instead of <img> for supporting multiple format of images (jpeg, webp).

<picture>
   <source type="image/jpeg" src="foo.jpg" />
   <img src="foo.webp" alt="Bar" />
</picture>

Change History (7)

This ticket was mentioned in PR #440 on WordPress/wordpress-develop by prionkor.


11 days ago

  • Keywords has-patch added

Add wp_get_attachment_image filter in output of wp_get_attachment_image() Trac ticket https://core.trac.wordpress.org/ticket/50801

Trac ticket:

#3 @prionkor
11 days ago

  • Keywords dev-feedback added

This ticket was mentioned in Slack in #core by sisir. View the logs.


10 days ago

#5 @SergeyBiryukov
10 days ago

  • Milestone changed from Awaiting Review to 5.6

This ticket was mentioned in PR #447 on WordPress/wordpress-develop by donmhico.


9 days ago

  • Keywords has-unit-tests added

Return a filter in wp_get_attachment_image(). Props to @prionkor for https://github.com/WordPress/wordpress-develop/pull/440. I initialized $attachment, add unit test, and filter docs.

Trac ticket: https://core.trac.wordpress.org/ticket/50801

#7 @prbot
7 days ago

prionkor commented on PR #447:

@donmhico Thank you! Appreciate it!

Note: See TracTickets for help on using tickets.