WebP is supported in the GD image toolkit.
As noted in the change record, you can check whether your version of PHP has WebP support by going to admin/reports/status/php#module_gd
.
What if I am using Imagemagick?
If you do a lot of image processing on your site, you may be using the ImageMagick toolkit via the ImageMagick contrib module. In this case, it doesn't matter if the GD support is enabled because Drupal is using Imagemagick, not GD.
So first, check your image toolkit at /admin/config/media/image-toolkit
. If you are using ImageMagick, you need to do the following:
- Click Image formats accordion title on
/admin/config/media/image-toolkit
.
- In Enable/disable image formats, scroll down to WEBP and set
enabled: true
.
- Save.
This will now let you convert to WebP for your image styles. (/admin/config/media/image-styles
)
What if I am using responsive images?
If you are using responsive image styles on your site via the core Responsive Image module, and you convert all your image styles to WebP, you will break support for older versions of Safari and Internet Explorer, which do not support WebP. (caniuse webP)
This is something the WebP module handles automatically, but core does not. So if you convert everything to WebP and call it a day, you will break your site for some users.
Unfortunately, core's Responsive Image module only supports breakpoints based on viewport size, but the correct approach is to set the type
on the tag, which core does not allow you to do. There is a drupal.org issue about this.
Workarounds:
- Use the WebP or ImageOptimize WebP modules instead of core.
- For each responsive image style (
/admin/config/media/responsive-image-style/MY_STYLE
), use image styles converted to WebP for all the breakpoints, and then use a non-WebP image style as the Fallback image style.