Problem/Motivation

This is a follow-up of #3136443: Webp support. The compatibility with the webp module only works with use_imagecache_root disabled. The cause of this is that webp removes the original file extension.

This used to work with stage_file_proxy and this old patch:
https://www.drupal.org/project/stage_file_proxy/issues/3136443#comment-1...

It basically added some possible extensions to the paths, which is not ideal.

There is also this issue in the webp issue queue, which is about adding the original extension to the URLs and therefore fix the issue:
#3281606: Rendering duplicate images when the original images have the same name but different extension

Steps to reproduce

  • Enable the use_imagecache_root configuration
  • Try to load images generated with the webp module using stage_file_proxy

Proposed resolution

TBD

Remaining tasks

  • Figure out if this should be solved in stage_file_proxy or the webp module.

User interface changes

None

API changes

None

Data model changes

None

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

Lukas von Blarer created an issue. See original summary.

luksak’s picture

Issue summary: View changes
luksak’s picture

Issue summary: View changes

smustgrave made their first commit to this issue’s fork.

smustgrave’s picture

Status: Active » Needs review

tried applying the old patch. Are you saying that works?

neelam.chaudhary’s picture

StatusFileSize
new1.73 KB

If the webp generated images are available locally then the file_exists check returns TRUE and the the local image gets rendered but if the file has been uploaded and is supposed to render the first time then the webp file is not yet generated and the file_exists returns false and it redirects the url to remote.
This patch will check all the possible ext of images and if the image is found then it will not be a redirect and the local file is returned.

smustgrave’s picture

Status: Needs review » Needs work

Just merged #3282542: Add a lock around retrieving upstream files could you test to see if you are still experiencing the issue on the dev branch?

The ProxySubscriber was deprecated in that merge.

deviantintegral’s picture

I just tested webp images and they work fine for me. However, it's not yet configured using responsive images in case that has something to do with triggering the bug.

godotislate made their first commit to this issue’s fork.

godotislate’s picture

Opened https://git.drupalcode.org/project/stage_file_proxy/-/merge_requests/34 for a different approach of using a local file entity query to find a matching local file entity URI for the imagecache root.

smustgrave’s picture

Thank you @godotislate have you tried the latest 2.0.x dev branch to see if the issue still exits?

zcht’s picture

smustgrave’s picture

So for patch #8 since it’s using a now deprecated approach can you test to see if the latest changes to 2.xdev fixes the issue

Same for the merge request. If the issue is still present then the MR needs to be rebased and then tested

dziabodo’s picture

StatusFileSize
new520 bytes

Hey,

The problem with webp is that we don't give drupal the ability to generate the image, when we invert the arrays and call webp first, drupal will capture the missing image and generate it.

    // Webp support.
    if (str_ends_with($relative_path, '.webp')) {
      $paths[] = str_replace('.webp', '', $relative_path);
      $paths = array_reverse($paths);
    }

Before Revers :

['styles/medium/public/2023-01/1516934428429_5.jpg.webp ', 'styles/medium/public/2023-01/1516934428429_5.jpg'];

So we can do call first to image without webp and drupal has time for generate missing images.

smustgrave’s picture

@dziabodo

Thank you just want to confirm the MR and current 2.0.x-dev did not fix it for you?

dziabodo’s picture

Yeah @smustgrave, problem still existed, but after revers array images back

smustgrave’s picture

Thank you for checking. Can someone confirm if $17 solves the issues for them? DOn't have webP setup locally or on any projects.

antoniya’s picture

#17 solved the issue for us but I do have to note that we are using core's built-in convert effect for WebP image styles and not the contributed module (as described in the original issue for WebP support linked in the IS).

smustgrave’s picture

Okay if no objection by tomorrow I'll merge in #17. Will track under the Meta if we can get plenty of testing.

  • smustgrave committed bea4ebaa on 2.0.x
    Issue #3332930: use_imagecache_root doesn't work with webp
    
smustgrave’s picture

Status: Needs work » Reviewed & tested by the community
Parent issue: » #3334239: 2.0.3 Release

Merged #17. If still an issue please reopen!

If we can get heavy testing could probably do another release for https://www.drupal.org/project/stage_file_proxy/issues/3334239

smustgrave’s picture

Status: Reviewed & tested by the community » Fixed

Wrong status.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

kevinn’s picture

Don't get how you guys got this to work, the checkFileOrigin method is looking for:

public://example.webp
public://example

Which nether exists because the webp is being created by the webp module as a image style and of course public://example does not exist.
Here is a patch that checks for other file extensions.
Btw im using responsive images, maybe thats why it does not work for me.

luksak’s picture

Yes, same for me as described in #29. Could a maintainer re-open this please?

smustgrave’s picture

Would recommend opening a new ticket explaining your issue.

luksak’s picture

Ok, did so: #3349119: use_imagecache_root doesn't work with webp I used the exact same title and IS, since I am the creator of this issue as well. Feel free to change it accordingly.