4

According to the change record, Drupal 9.2 supports WebP for better image compression.

I've been using the WebP module on my 9.1 site to serve WebP images, but it has a performance-killing bug and I would like to use Core if possible.

So when I upgrade to 9.2, how can I replace the WebP module with core's WebP support?

I upgraded to 9.2, uninstalled WebP, and searched for WebP options, but couldn't find anything.

This Lullabot post said it should be supported in the Convert effect, but I don't see the option.

1 Answer 1

8

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:

  1. Click Image formats accordion title on /admin/config/media/image-toolkit.
  2. In Enable/disable image formats, scroll down to WEBP and set enabled: true.
  3. 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.
1
  • 1
    Note regarding the performance that there is a patch ready, and my aim would be to merge it in the next few days and get a stable release ASAP Commented Jan 30, 2022 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.