Declare compatibility with the webp format

Created on 10 April 2023, over 1 year ago
Updated 18 April 2023, over 1 year ago

Problem/Motivation

Since Drupal 9.2, the webp format has been fully supported out of the box in core. This module should likely add image/webp to the compatible mime types configuration.

Steps to reproduce

Configure an image style to convert images to webp format and observe that the images do not render.

Proposed resolution

Update the compatible mime-types from:

$library['compatible_mimetypes'] = ['image/gif', 'image/jpeg', 'image/png'];

to

$library['compatible_mimetypes'] = ['image/gif', 'image/jpeg', 'image/png', 'image/webp'];

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

✨ Feature request
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

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

Comments & Activities

  • Issue created by @luke.leber
  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania
  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    I updated the compatible mimetypes on my V10 test site. Line 92 in Juicebox.module:

    $library['compatible_mimetypes'] = ['image/gif', 'image/jpeg', 'image/png', 'image/webp'];

    That works as far as it goes, but I can't upload a webp image.

    Looking around various issue queue's for instance:

    https://www.drupal.org/project/webp/issues/3331986 πŸ’¬ Is this module needed? Active

    I can't tell if an additional module is needed to create a webp version of each image in each image style. Or how we should proceed. Even outside of the Juicebox module, for instance say using the article content type, I can't upload a webp image. I can't tell how far core support for webp goes and whether an additional module is required.

    I can try the webp module on my test system if that helps ... but if Core is supposed to enable this capability and we just need an adjustment or two in Juicebox, it could be a waste of time.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    Looking further, the Juiceboxbuilder-Pro program that is used for building galleries on a PC or MAC does not support webp. It builds an xml file listing all your images and the order they display in, together with Juicebox Options you've chosen. You then upload the gallery xml file to your Drupal site (I use a FTP client), then embed the gallery in a content type (I use a specially created JuiceboxGallery content type). After the gallery is embedded in the content type, the content type will have a URL that can be accessed through a menu or a view. This process lets the PC or MAC do what it's good at and the web site do what it is good at.

    In the Juicebox help forums there have been several feature requests to support webp. These go back several years. I will post an updated feature request but given the lack of progress so far, I would not be optimistic. One of the moderators on Juicebox suggested perhaps editing the xml file to change the file type to webp. That would assume you had created both jpg and webp files on your PC. We still need to confirm that the Juicebox Javascript program (which is obfuscated an not open source) would process webp files from the xml file.

    I'm not sure this is worth the effort. But I will pursue it a bit further and tweak them about updating their software.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    Here is the text from a JuiceBox forum support question about webp:

    JuiceboxBuilder-Pro does not currently support webp as an image format.
    Please see this FAQ:
    Will Juicebox load things other than images?

    However, you could use webp images in a Juicebox gallery but you'd need to build the gallery manually (adding an entry to the gallery's 'config.xml' file for each webp image and then copying your image and thumbnail webp files to the gallery's 'images' and 'thumbs' folders respectively). As long as the browser being used to view the gallery supports webp images (please see here for details), the images will be displayed in the gallery.

    If you like, you could post this idea (support for webp images) as a suggestion in the Feature Requests forum thread.
    This keeps all the requests together and ensures that they will not be overlooked by the developers.
    I do not know the likelihood of any ideas being implemented in future versions but this is certainly the best place for all ideas.
    Thank you!

    Implication is that the JuiceboxJavascript might work with webp if you got an gallery xml file linking to webp. You'd have to manually edit the xml file AFTER you created the gallery with jpgs and you'd have to create a set of both jpg and webp files for both Gallery images and thumbnails. This of course is with Juiceboxbuilder-Pro (or Lite). Possibly if you built the gallery entirely within Drupal (no use of JBPRO) by sticking images right into a content type and using Juiceboxformatting on them, you could go direct to webp and skip the jpgs.

    No terrible puns about the Juice not being worth ... from me but this sure wouldn't be my priority.

    An open source (clean room) version of the Javascript and even the Gallery Builder would be more helpful.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    Stumbled across:

    https://www.drupal.org/project/drupal/issues/3282679 ✨ Allow user-uploaded WebP images everywhere in Drupal by default: image fields, media library, text editors Needs work

    which indicates that webp support is a Work in Progress in Drupal 10. It sounds like a desirable work in progress but I doubt we want to get the contrib Juicebox module out in front of core changes.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    For what it's worth: I have been having a fit getting the JuiceboxPro (JBPRO) builder software (with which I have over the years built well over 100 photo galleries a.k.a. albums). Many posts and many hours later I have a version that work on an "alternate" profile (or username) on my Windows computer.

    JBPRO will NOT let you directly embed webp images. There is one help post that says you could edit the xml file of the album you created and change jpgs to webps. Of course, by implication you would need to create webp versions of your images (both full ones and thumbnails). So I created an album with some pictures of my cat. I saved the original and then made a separate directory for the webp version. Each album comes with a /images and a /thumbnails directory as well was a album_name.xml file. You have to edit the xml file to go a global replace of .jpg to .webp for the images.

    Then I uploaded both versions of the albums to my local (Wampserver) test site. Then I embedded the albums (another topic) into a JuiceboxGallery content type ... basically using copy and paste from an older embedded album and changing one or two items. Each album gets it's own URL. They were immediately visible and accessible on my test site.

    I use a FTP process (Beyond Compare) to move images around both on my local machine and to my hosted web site. By the end of this month (April 2023) I should have a 10.0.8 ? whenever that's released on my hosted site so anyone can see the webp album.

    With this approach I don't get caught up with any limits on file types that Drupal (or Juicebox) lets you upload.

    I don't know if any gains in efficiency (storage or performance) are worth it. Certainly editing completed xml files by hand is not desirable or efficient but I wouldn't hold my breath for JBPRo to be upgraded to support webp.

Production build 0.71.5 2024