Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The ImageAPI Optimize WebP module generates .webp derivatives for a given non-webp source image. Stage File Proxy attempts to fetch the non-existant .webp source file, instead of the .jpg (or other) source.
The ImageAPI Optimize WebP module appends the .webp extension to the original filename, e.g. imagename.jpg.webp, this differs from the webp project for which I have linked the related issue.
Patch to follow.
Comment | File | Size | Author |
---|---|---|---|
#29 | webp-support-3171559-29.patch | 1.41 KB | Falco010 |
#19 | webp-support-3171559-19.patch | 1.19 KB | afi13 |
#12 | interdiff-5-12.txt | 1.03 KB | marcoscano |
#12 | 3171559-12.patch | 3.93 KB | marcoscano |
| |||
#10 | db-log.png | 59.65 KB | mherchel |
Comments
Comment #2
MattKD CreditAttribution: MattKD at Chromatic commentedThis patch is based on the one in the related issue, but has been updated to work with the ImageAPI Optimize WebP module instead.
Comment #3
gregglesThere's a patch so updating status.
Comment #4
geek-merlinPostponing this on the other issue.
Comment #5
markdorisonPatch fails to apply after a change in this commit for D9 support.
I am leaving this marked Postponed per #4, but I am attaching a re-rolled patch with an interdiff for the change I made to get it to keep it in line with the D9 changes.
Comment #6
mherchelNote that WebP support just landed in core See #2340699: Let GDToolkit support WEBP image format.
It would be nice if we could hard-code the webp support in the meantime until #3173364: Provide a hook so modules can provide more "derived-from" candidates lands
Comment #7
gregglesSince there hasn't been much progress on 2340699 it seems like a fine idea to add this support here.
I wonder what module would theoretically provide the webp hook even once 2340699 lands. Maybe stage_file_proxy would which seems like it adds to the argument to add this support here for now.
@mherchel @markdorison are you vouching for this patch? Is it RTBC in your perspective?
Looking at the first comment:
> has been updated to work with the ImageAPI Optimize WebP module instead.
It seems like we should ideally support whatever are the most common and support several of them (i.e. both vs instead).
Comment #8
markdorison@greggles We have been using the #5 patch on one of our sites since September 2020 without issue, so from our perspective this is RTBC.
Comment #9
mherchelI haven't tested out the patch yet. Note that I'm currently using the regular Webp module.
I'll make a point to test this out in the coming days.
Comment #10
mherchelIt's not working for me.
Below are the errors that I'm seeing. What am I doing wrong?
Comment #11
mherchelComment #12
marcoscanoThe webp module converts image derivatives only, so the code that tries to grab the original image should be skipped if we are dealing with a webp image. Here's a simple check to skip it, which seems to make it work in my testing.
Comment #13
mherchelThanks @marcoscano!
Just tested this out and it works wonderfully!
Comment #14
markdorisonHoping to get this committed but I have one question:
Why are we calling
exit;
in this case? Is that intentional?Comment #15
marcoscanoWe are not really changing it here, are we? The git diff makes it look more complex than it should, but this chunk is already part of the original code: https://git.drupalcode.org/project/stage_file_proxy/-/blob/8.x-1.x/src/E...
Comment #17
markdorison@marcoscano You are correct. Thanks for pointing that out!
Comment #19
afi13 CreditAttribution: afi13 commentedpatch #12 doesn't work for me, added a small fix
Comment #20
ericdsd CreditAttribution: ericdsd commentedPatch #12 worked for me against 8.x-1.1
Patch# could not be applied.
Comment #21
gregglesI made https://www.drupal.org/project/stage_file_proxy/releases/8.x-1.2 that includes this code so folks don't have to mess with patch files on the stable release.
Patch #19 seems like it could be problematic since it looks for .webp anywhere in the string and is case sensitive (but I don't use webp a ton, so not sure).
Comment #22
mattjones86This doesn't work for me with
imageapi_optimize_webp
enabled. This seems to be due to it skipping the download of original files in this block:This seems to be because the remote server hasn't yet generated it's image style from the original. I'm not sure why this isn't triggering the remote to generate it's imagecache, but either way it seems strange not to honour the
use_imagecache_root
setting.Example:
Comment #23
froboyI had a similar problem as @mattjones86 and the patch in #19 resolved it for me. It's possible that should be reconsidered.
Comment #24
couloir007 CreditAttribution: couloir007 commentedI'm using Drupal 9.3.14's built in webp image style and all my images are generated as "image_name.jpg.webp", or the equivalent, and I've tried the latest stable release and the dev release with this patch and I can't get it to work. I notice in the patch it was looking for a different pattern so I adjusted, but still couldn't get it work.
Thanks!
Comment #25
yonailo CreditAttribution: yonailo commentedI was experiencing infinite 302 redirection loops, my settings are "imagecache root" enabled / "hotlink" disabled.
Patch #19 solved the issue for me too.
Comment #26
heddn[#417107-21] is basically the same thing.
Comment #27
endrukk CreditAttribution: endrukk commentedPatch #19 working for me too Drupal 9.4.7 after
drush if --all
@couloir007 have you tried flushing image cache
Comment #28
stijnhau CreditAttribution: stijnhau at Open Up Media commentedPatch failes to install with version 1.3 and 1.4
Comment #29
Falco010In latest version 2.0.2 for Drupal 10, this patch/fix did not work properly anymore.
Hereby a rerolled patch which should apply to 2.0.2 and fix the issue.