Allow user-uploaded WebP images everywhere in Drupal by default: image fields, media library, text editors

Created on 27 May 2022, over 2 years ago
Updated 13 September 2023, over 1 year ago

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.

✨ Feature request
Status

Needs work

Version

11.0 🔥

Component
Image system  →

Last updated 1 day ago

Created by

🇮🇳India prashant114606

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs review almost 2 years ago
  • 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.

  • Status changed to Needs work almost 2 years ago
  • 🇫🇷France andypost

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

  • 🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    Re-roll the patch For 10.1 version .

  • 🇮🇳India Ajeet Tiwari

    Added reroll for 10.1.x.

  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India Ajeet Tiwari

    Added reroll for 10.1.x.

  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States smustgrave

    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.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India TanujJain-TJ

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

  • 🇮🇳India TanujJain-TJ

    Fixed Tests on #19.

  • heddn Nicaragua

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

  • 🇫🇷France duaelfr Montpellier, France

    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 Nicaragua

    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.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    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 Nicaragua

    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.

  • 🇺🇸United States smustgrave

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

  • 🇮🇹Italy mondrake 🇮🇹

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

  • 🇫🇷France andypost

    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)$/');
    
  • 🇫🇷France andypost

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

  • 🇮🇳India gkaurkalra

    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. on inspecting and removing query params or cache token added to image url, preview worked fine. Is there a solution in place for that ?

  • 🇸🇮Slovenia lynxlynxlynx

    `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.

Production build 0.71.5 2024