Provide drimage support for core Webp

Created on 4 October 2023, 7 months ago
Updated 3 April 2024, 16 days ago

Problem/Motivation

I wanted to ask if it would be possible to also support core Webp functionality and if so how difficult this would be?

Since Drupal 9.2, Webp is supported in core and since the last browser that did not support Webp "Catalina" will not be supported itself later this autumn, we thought it would be a good idea to just use core Webp in our site.

We also wanted to opt to provide drimage, but Webp and drimage are only possible when using additional contrib modules.

Ticket about core install profile switching to Webp. 📌 Add webp image conversion to core's install profile's image style Fixed

Steps to reproduce

How to use webp in core.

How to add the convert Webp effect, explained with images.

Proposed resolution

I quickly went through the module and wondered if my initial assessment would be correct to get this working.

Could this functionality be implemented by an extra checkbox "Enable core Webp support" with a check that Webp is indeed enabled on the site before it is shown.

With then in the controller an additional image style convert effect added, with the Webp extension.

Am I in the right direction or what else would be needed to make this a reality? I am rather new in terms of the drimage module.

Remaining tasks

Write out the necessary steps in more detail and provide proof of concept code or simply work out the functionality.

User interface changes

Additional selection field to use Webp support from core on the automatically generated image styles.

API changes

/

Data model changes

Dont know if this would bring any data model changes, definitely fill it in if it does.

Feature request
Status

Fixed

Version

2.2

Component

Code

Created by

🇧🇪Belgium dtfabio Ninove

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @dtfabio
  • 🇧🇪Belgium weseze

    Certainly a direction I would like go with for drimage.
    Supporting webp natively from core looks like the preferred way to go. For now webp was added more as an afterthought ...

    Adding a checkbox will probably not be enough.
    The current webp implementation will (I think) be incompatible with the the new webp implementation you propose. So theses 2 checkboxes would need to exclude one another...

    As far as the changes to the drimage delivery mechanism: On a high level your assumption seems good to me, but I would have to examine it more in depth. I personally have not worked (yet) with native Drupal webp so I'm uncomfortable giving directions here.

    If you are willing to work on this, I would be happy to review any patch/MR/fork you make.

  • Assigned to dtfabio
  • 🇧🇪Belgium dtfabio Ninove

    Hi weseze,

    I am currently at Drupal Con Lille and will try to make a first draft. To see if I can get this working.

    Greetings,

    Fabio

  • 🇧🇪Belgium DieterHolvoet Brussels

    All core shipped image styles now include standard webp conversion: https://www.drupal.org/node/3406267

  • Status changed to Needs review about 2 months ago
  • Issue was unassigned.
  • Assigned to dtfabio
  • Status changed to Active about 1 month ago
  • 🇧🇪Belgium dtfabio Ninove

    Hi Dieter,

    I will test the new version, so that this ticket can be put on RTBC.

    Greetings,

    Fabio

  • Status changed to Needs review 29 days ago
  • 🇧🇪Belgium dtfabio Ninove

    Hi Dieter,

    I finished testing the change, I have tested the module on three different Drupal instances.

    First on a clean D9 installation core recommended version 9.5.11 PHP versions 8.0 and 8.1

    Secondly on a clean D10 installation core recommended version 10.2.4, PHP version 8.1

    And lastly on our Calibrate DXP install profile core recommended version 10.2.3, PHP version 8.1

    Our install profile works with Imagemagic as the image toolkit and here I noticed that it did not take into account the status of Webp in the toolkit after the Drimage functionality was already enabled once (here I mean config wize, because the field was disabled on the form, but still enabled in config).

    So have added another check in the DrimageSettingsForm on line 178 after the check on image toolkit support to see if Core Webp is enabled. So that it automaticly disables when support is removed, just as happens when enabling the image optimise webp module.

    If you can review this change and it's ok for you, then I think this ticket may be put on RTBC.

    Greetings,

    Fabio

  • Issue was unassigned.
  • 🇧🇪Belgium dtfabio Ninove
  • 🇧🇪Belgium DieterHolvoet Brussels

    Just tested this one last time on another project and changing from ImageAPI Optimize WebP to core webp works perfectly. I'll merge this.

  • Pipeline finished with Skipped
    24 days ago
    #129707
  • Status changed to RTBC 24 days ago
  • Status changed to Fixed 24 days ago
  • 🇧🇪Belgium DieterHolvoet Brussels

    @weseze okay for you if I create a 2.3.0 release?

  • Status changed to Fixed 16 days ago
  • 🇧🇪Belgium DieterHolvoet Brussels

    I'll go ahead and create a new release.

Production build https://api.contrib.social 0.62.1