WordPress / performance

Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.
https://wordpress.org/plugins/performance-lab/
GNU General Public License v2.0
340 stars 91 forks source link

Use WebP image in templates #513

Open jjgrainger opened 1 year ago

jjgrainger commented 1 year ago

A couple of support tickets have been raised regarding using the WebP version of images in templates.

Currently, the plugin replaces images URLs to their WebP version in the WordPress content only.

Providing a way to use WebP outside of the content has been explored as part of a core patch (#155) but has been paused due to feedback on the wider WebP core patch.

As an initial step towards supporting WebP across templates, we could use hooks to modify the returned URL by core functions. As a starting point we can explore using the wp_get_attachment_image_src hook.

This could be optional by providing a custom filter in the plugin to allow developers to enable WebP support outside of the content. The filter could accept an array to provide more granular control over what image sizes should be returned as WebP if needed.

bethanylang commented 1 year ago

Tagging in @felixarntz and @adamsilverstein here for review. I agree based on what we've seen on the support forums that this is something that we should address at some point.

felixarntz commented 1 year ago

This is related to #523, however the two are a bit different.

@bethanylang Regarding the support requests around this, I believe they should notably become less once we have released #524, as then we basically go "all in" on WebP. This also means that issues like this one and #523 may be less urgent to address. We should still work on them probably, but I just want to point that out.