Problem/Motivation

Allow users to upload and manage images of Google's image format, WebP (https://developers.google.com/speed/webp)

Steps to reproduce

- Upload the image inside ckeditor with Webp extension

Proposed resolution

Remaining tasks

None.

User interface changes

Nothing.

API changes

Nothing.

Data model changes

Release notes snippet

Allow users to use images with .webp extension.

Issue fork drupal-3282679

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prashant114606 created an issue. See original summary.

prashant114606’s picture

Issue summary: View changes

cilefen’s picture

Version: 9.3.x-dev » 9.5.x-dev
wim leers’s picture

Title: Add webp support for Images in CKEditor » Allow user-uploaded WebP images everywhere in Drupal by default: image fields, media library, text editors
Component: ckeditor5.module » image system
Issue tags: +front-end performance
Related issues: +#2340699: Let GDToolkit support WEBP image format

Thanks for proposing this! 😄

Alas:

  1. This is also not supported for CKEditor 4 — see \Drupal\editor\Form\EditorImageDialog::buildForm().
  2. AFAICT nothing else in Drupal core supports WebP: not image fields, not media library, et cetera. The CKEditor 5 module cannot and should not be the only/first place to support it.
  3. Per https://www.drupal.org/node/3171135, AFAICT we cannot even assume yet that Drupal can support WebP on all environments.

So … moving to a different subsystem and retitling to capture your intent.

jshimota01’s picture

I didn't search deeply through previously submitted items / issues but found this near the top of the list and wanted to add.

The default installation 'Allowed File Extensions' is legacy from d7. It needs to dynamically add 'webp' support. Since a simple check server side can determine if webp is allowed - the default value should start with webp enabled.
Woe is the poor slob who starts building a website and trys putting a webp logo on -

joshuautley’s picture

Sometimes I wonder what's going on in the Drupal community. Let's get this done. Three lines of code and we are saving so much space on servers worldwide and improving the UX for all site visitors.

And while we're at it, make webM fully supported as well.

Hoops are fun, but shouldn't be necessary.

joshuautley’s picture

This video helped us implement a solution with inserting media with image styles (convert to webP) using CKEditor.

https://www.youtube.com/watch?v=JuCbL8g96Iw

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jcnventura’s picture

This should make sure that all the currently supported GD image formats and not only webp are supported everywhere. I've referenced as parent the issue where support for all GD supported formats was added to Drupal.

jcnventura’s picture

StatusFileSize
new2.82 KB

Uploading the current state of the MR, so that I can use it from composer-patches without opening the sites to an easy code injection vulnerability.

jcnventura’s picture

Status: Active » Needs review
Issue tags: +Needs tests

And let's start the testbots while we're doing this, even if it does need a few tests for these changes.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new150 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

andypost’s picture

Issue tags: +Needs reroll

needs re-roll for 10.1 or/and MR needs retarget

prem suthar’s picture

StatusFileSize
new2.03 KB

Re-roll the patch For 10.1 version .

Ajeet Tiwari’s picture

StatusFileSize
new2.83 KB

Added reroll for 10.1.x.

Ajeet Tiwari’s picture

Status: Needs work » Needs review

Added reroll for 10.1.x.

smustgrave’s picture

Status: Needs review » Needs work

Hiding patches #15 (missing tests) and #16 (missing part of fix)

Also not sure if there should be additional tests or not? Will defer to others.

tanuj.’s picture

Status: Needs work » Needs review
StatusFileSize
new3.45 KB
new1.07 KB
new491 bytes

adding new patch for drupal 10.1 as earlier patches were incomplete, please review.

Status: Needs review » Needs work

The last submitted patch, 19: 3282679-19.patch, failed testing. View results

tanuj.’s picture

Status: Needs work » Needs review
StatusFileSize
new5.33 KB
new1.57 KB

Fixed Tests on #19.

heddn’s picture

Issue tags: -Needs reroll

Is there any way to do an audit of existing widget configuration to make sure webp is the default across the board?

duaelfr’s picture

Hey! Thank you for working on this issue!
I learnt a few days ago that AVIF was a serious challenger of WebP. Today, it's supported everywhere but on Edge so it's maybe not the most urgent format to integrate. I thought it might be interesting to do both at the same time or open a follow up issue if you want to wait for Edge support, though.

heddn’s picture

If this goes in easily, then we can circle back on avif and do it next. But let's do them a distinct things as we'll have less organizational churn deciding on both at the same time. Make it easy.

smustgrave’s picture

Status: Needs review » Needs work

This just appears to be changing the default behavior when installed.

There are a number of config files that maybe should be updated as well.

Not sure if any update hook is needed, would assume it could be disruptive to existing sites.

Maybe could be covered by change record.

heddn’s picture

Issue tags: +Needs change record

This just appears to be changing the default behavior when installed.

Yup, that's what is going on here. Its a long over due change. The default install should support webp so folks use the more performance file formats.

No update hook should be added or wanted. But a change record is needed to highlight this new default. Tagging appropriately.

smustgrave’s picture

In that case think the config should be updated and maybe can go back to review.

mondrake’s picture

#23 AVIF support is not so straightforward, at least with GD: #3202016: Let GDToolkit support AVIF image format. Imagemagick is a better chance.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

andypost’s picture

Most of changes already commited to 10.2 but there's some leftovers #3275557-14: Add webp image conversion to core's install profile's image style

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:

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)$/');
andypost’s picture

Moreover Umami can convert the most of the default content images to WebP for smaller size, but better to create separate issue

jiggli’s picture

I have changed the allowed file extension and added webp. But when i upload a webp, no preview is shown on image upload form, or the display. What could be the possible reason for that ?

Edit - found an issue already in place for it with patch to solve. it
https://www.drupal.org/project/webp/issues/3296075
P.S updating webp module will solve it.

lynxlynxlynx’s picture

`DEFAULT_EXTENSIONS` in `core/modules/file/src/Upload/FileUploadHandler.php` definitely needs extending as well. This is the list of allowed extensioned used when no custom extension validator is used in Form API.

andypost’s picture

now AVIF is added, would be great to prefer it when available instead of WEBP

ref #3202016: Let GDToolkit support AVIF image format

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.