Problem/Motivation

Image bandwidth would reduce by ~25%-34% with conversion to webp. See https://developers.google.com/speed/webp.

The lone holdout to webp support is older versions of Safari (see https://caniuse.com/webp). Safari supports webp, but OSX Catalina doesn't, at all, you get a broken image thing instead of a photo. Catalina will loose support later this fall, so we can start planning for this feature NOW so it will land in 10.1.

One datapoint is that the fermilab network is actively blocking Catalina installs - which is not a huge userbase but it does mean people are going to get forced off it altogether.

https://news.fnal.gov/2022/10/macos-catalina-v10-15-end-of-life-friday-o...)%20has%20reached%20its%20end,from%20accessing%20the%20Fermilab%20network

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Drupal core install profile shipped image styles now convert to webp, this will be effective for new installations. Site owners may want to consider adding a webp conversion step to their own image styles.

CommentFileSizeAuthor
#12 3275557-12.patch12.32 KBandypost
#12 interdiff.txt293 bytesandypost
#9 3275557-9.patch12.04 KBandypost

Comments

heddn created an issue. See original summary.

catch’s picture

catch’s picture

catch’s picture

I think we can do this now that Catalina is out of support, but I've asked other committers what they think too.

catch’s picture

Note that #3213491: Add fallback format support to responsive images would make OSX Catalina a non-issue, but I'm not sure we should block this issue on that one. It'll still be useful later on for AVIF and other formats.

catch’s picture

Issue summary: View changes
catch’s picture

Discussed this with @lauriii and he also thinks we should go ahead here despite Catalina - given it's been out of support since November, Apple's not supporting it so neither should we.

The core change won't prevent sites reverting back to png or using the contrib webp module with fallback support if they still want to, it's just making defaults (much) faster/smaller for everyone else.

catch’s picture

Untagging now there's been a +1 from a front end framework manager, and looking at things like fermilab dropping support has also reassured me it should be fine. Also anecdotally I know one person who was still on OS Catalina last year, and I asked them last week if they still are, and they're not any more. We can't get proper usage data because Safari reports Big Sur as Catalina, but there's every other sign that people are getting off it.

andypost’s picture

Version: 10.0.x-dev » 11.x-dev
Status: Active » Needs review
StatusFileSize
new12.04 KB

It probably needs to CR and upgrade path but let;s start from all places I can find with git grep 'png gif jpg jpeg'

andypost’s picture

Probably it makes sense to convert images in Demo umami from jpeg as each file becoming smaller more the 15KB

find . -type f -name "*.jpg" -exec sh -c 'convert "$1" "${1%.jpg}.webp"' _ {} \;

$ ls -la core/profiles/demo_umami/modules/demo_umami_content/default_content/images 
-rw-rw-r--    1 web-user web-grou     66852 Jun 15 01:07 borscht-with-pork-ribs-umami.jpg
-rw-r--r--    1 web-user web-grou     45164 Jun 15 01:14 borscht-with-pork-ribs-umami.webp
-rw-rw-r--    1 web-user web-grou    100481 Jun 15 01:07 chili-sauce-umami.jpg
-rw-r--r--    1 web-user web-grou     80054 Jun 15 01:14 chili-sauce-umami.webp
-rw-rw-r--    1 web-user web-grou     30431 Jun 15 01:07 chocolate-brownie-umami.jpg
-rw-r--r--    1 web-user web-grou     16326 Jun 15 01:14 chocolate-brownie-umami.webp
-rw-rw-r--    1 web-user web-grou     62307 Jun 15 01:07 crema-catalana-umami.jpg
-rw-r--r--    1 web-user web-grou     42422 Jun 15 01:14 crema-catalana-umami.webp
-rw-rw-r--    1 web-user web-grou     36097 Jun 15 01:27 heritage-carrots.avif
-rw-rw-r--    1 web-user web-grou     36372 Jun 15 01:07 heritage-carrots.jpg
-rw-r--r--    1 web-user web-grou     16888 Jun 15 01:14 heritage-carrots.webp
-rw-rw-r--    1 web-user web-grou    114984 Jun 15 01:07 home-grown-herbs.jpg
-rw-r--r--    1 web-user web-grou     97352 Jun 15 01:14 home-grown-herbs.webp
-rw-rw-r--    1 web-user web-grou     70160 Jun 15 01:07 mediterranean-quiche-umami.jpg
-rw-r--r--    1 web-user web-grou     50504 Jun 15 01:14 mediterranean-quiche-umami.webp
-rw-rw-r--    1 web-user web-grou     49938 Jun 15 01:07 mojito-mocktail.jpg
-rw-r--r--    1 web-user web-grou     30354 Jun 15 01:14 mojito-mocktail.webp
-rw-rw-r--    1 web-user web-grou     92740 Jun 15 01:07 mushrooms-umami.jpg
-rw-r--r--    1 web-user web-grou     72760 Jun 15 01:14 mushrooms-umami.webp
-rw-rw-r--    1 web-user web-grou     76171 Jun 15 01:07 oatmeal-fruit-syrup-topping.jpg
-rw-r--r--    1 web-user web-grou     55288 Jun 15 01:14 oatmeal-fruit-syrup-topping.webp
-rw-rw-r--    1 web-user web-grou     81301 Jun 15 01:07 pizza-umami.jpg
-rw-r--r--    1 web-user web-grou     59940 Jun 15 01:14 pizza-umami.webp
-rw-rw-r--    1 web-user web-grou    100645 Jun 15 01:07 supermarket-savvy-umami.jpg
-rw-r--r--    1 web-user web-grou     78198 Jun 15 01:14 supermarket-savvy-umami.webp
-rw-rw-r--    1 web-user web-grou     38674 Jun 15 01:07 thai-green-curry-umami.jpg
-rw-r--r--    1 web-user web-grou     22930 Jun 15 01:14 thai-green-curry-umami.webp
-rw-rw-r--    1 web-user web-grou     30490 Jun 15 01:07 umami-bundle.png
-rw-rw-r--    1 web-user web-grou    261638 Jun 15 01:07 vegan-brownies-hero-umami.jpg
-rw-r--r--    1 web-user web-grou    234494 Jun 15 01:14 vegan-brownies-hero-umami.webp
-rw-rw-r--    1 web-user web-grou    109982 Jun 15 01:07 vegan-chocolate-nut-brownies.jpg
-rw-r--r--    1 web-user web-grou     87512 Jun 15 01:14 vegan-chocolate-nut-brownies.webp
-rw-rw-r--    1 web-user web-grou     65650 Jun 15 01:07 vegan-chocolate.jpg
-rw-r--r--    1 web-user web-grou     49282 Jun 15 01:14 vegan-chocolate.webp
-rw-rw-r--    1 web-user web-grou    225830 Jun 15 01:07 veggie-pasta-bake-hero-umami.jpg
-rw-r--r--    1 web-user web-grou    289676 Jun 15 01:14 veggie-pasta-bake-hero-umami.webp
-rw-rw-r--    1 web-user web-grou    102082 Jun 15 01:07 veggie-pasta-bake-umami.jpg
-rw-r--r--    1 web-user web-grou     77416 Jun 15 01:14 veggie-pasta-bake-umami.webp
-rw-rw-r--    1 web-user web-grou     65418 Jun 15 01:07 victoria-sponge-umami.jpg
-rw-r--r--    1 web-user web-grou     46326 Jun 15 01:14 victoria-sponge-umami.webp
-rw-rw-r--    1 web-user web-grou     31072 Jun 15 01:07 watercress-soup-umami.jpg
-rw-r--r--    1 web-user web-grou     15878 Jun 15 01:14 watercress-soup-umami.webp
andypost’s picture

StatusFileSize
new293 bytes
new12.32 KB

fix cspell

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Change looks good.

Would be nice to see this get into 10.2 early.

longwave’s picture

Status: Reviewed & tested by the community » Needs review

I searched for "jpeg", excluding tests and "webp", and found a few other places we might want to consider adding webp while we are here - I haven't checked any of these in detail and not sure it should be added, but we should at least consider these:

core/assets/scaffold/files/gitattributes:*.jpeg    -text diff
core/assets/scaffold/files/robots.txt:Allow: /core/*.jpeg
core/assets/scaffold/files/robots.txt:Allow: /profiles/*.jpeg
core/lib/Drupal/Core/File/file.api.php:  $cdn_extensions = ['css', 'js', 'gif', 'jpg', 'jpeg', 'png'];
core/modules/ckeditor5/ckeditor5.ckeditor5.yml:          types: ["jpeg", "png", "gif"]
core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php:      'file_validate_extensions' => ['gif png jpg jpeg'],
core/modules/editor/src/Form/EditorImageDialog.php:        'file_validate_extensions' => ['gif png jpg jpeg'],
core/modules/file/src/Upload/FileUploadHandler.php:  const DEFAULT_EXTENSIONS = 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp';
core/modules/image/src/Plugin/Field/FieldType/ImageItem.php:    $extensions = array_intersect(explode(' ', $settings['file_extensions']), ['png', 'gif', 'jpg', 'jpeg']);
core/modules/media/media.install:  $files = $file_system->scanDirectory($source, '/.*\.(svg|png|jpg|jpeg|gif)$/');
longwave’s picture

catch’s picture

I think it's worth leaving the image derivative issue (this one) and the upload issues separate, unless they really need to be combined - just to have less things to to worry about in each.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

OK, let's just land this here, and leave the other one open to handle the remaining cases.

longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed a87a72fa063 to 11.x (10.2.x). Thanks!

  • longwave committed a87a72fa on 11.x
    Issue #3275557 by andypost, catch, heddn: Add webp image conversion to...
longwave’s picture

Status: Reviewed & tested by the community » Fixed

Crossposted with the bot.

catch’s picture

Issue summary: View changes
Issue tags: +10.2.0 release highlights

Added a release notes snippet, don't think there's anything else to mention so leaving a CR. Also tagging for 10.2.0 release highlights since this will be a nice performance improvement on new sites. Also not sure how many site admins actually know the webp option is in core.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

adamsilverstein’s picture

Great to see this merged into Drupal core!

I noticed that the Lighthouse Stack Pack for Drupal for the `modern-image-formats` audit point to this documentation : https://www.drupal.org/docs/core-modules-and-themes/core-modules/image-m... which makes no mention of WebP or how to enable modern image formats. Should we update the documentation here, or is there a better place we can link the Stack Pack message? Since the Stack Packs are open source we can proposes changes for the link or recommendation text directly on the repository.

ericdsd’s picture

Even if i've been waiting for real webp support for a long time, I sadly think doing so without fixing at least Add fallback format support to responsive images is not a really a news, as lot of old mac users cannot update their os (eg. lots of artists still use macbook pro 2012, not mentioning poor people). It means that doing this we'll collectively enforce Apples programmed obsolescence by providing massivelly degraded web experience for people not able to change their computer every 6 years as Apple now forces people to to). In a more general way we should provide a more robust out of the box fallback methods to ease adopting new images and video formats like avif.
Do you think there is a chance to see fallback issue embedded in 10.2 too ?

catch’s picture

This issue didn't actually add webp conversion to core's shipped image styles at all, just as an option for upload to image fields (which is fine, but not what the issue was originally for) I've opened #3406267: All core shipped image styles should include webp conversion to do that bit.

catch’s picture

Untagging from 10.2.0 release highlights, hopefully we can get the follow-up into 10.3/11.x