You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider supplying modern image format in response to wp_get_attachment_image() #2299
We should consider filtering the response to wp_get_attachment_image() to handle additional cases where a theme may be printing an image in ways other than the_content() and the_post_thumbnail().
And, right now we are using the post_thumbnail_html filter for the featured image, but we could use the wp_get_attachment_image filter as the bug reporter suggested. However, this filter would also include any image echoed using the wp_get_attachment_image() function, which is used for featured images and is also typically used by other plugins. So, I'm not sure whether the Modern Image Formats plugin should also handle those images.
Also, while trying to replicate this bug, I noticed that (Using Twenty Twenty-One) Image Widgets or widget blocks containing the Image block and Gallery block don’t get their sources replaced with modern image formats because the webp_uploads_wrap_image_in_picture() function only allows the the_content context, while widgets send the widget_block_content context.
Activity
westonruter commentedon Jan 6, 2026
If we replace all images returned by
wp_get_attachment_image()then we should make sure that they are being output in theBODYand not theHEAD.b1ink0 commentedon Oct 1, 2026
With the PR #2451 merged I think this issue can be closed as well.
adamsilverstein commentedon Oct 23, 2026
+1 Closing as fixed.
Feel free to re-open if we missed something @westonruter