Webp derivatives not refreshed when files stored in sub-directory

Created on 25 March 2024, 8 months ago
Updated 21 May 2024, 6 months ago

Problem/Motivation

Webp derivatives are not refreshed correctly when the image file is stored in a subdirectory. Currently the webp derivative is stored in the root of the style directory, even if the original file is stored in a subdirectory. For example if the directory is configured as [date:custom:Y]-[date:custom:m] the uploaded file will be files/2024-03/image.jpg but the webp derivative will be files/styles/my-style/public/2024-03image.jpg.
The derivatives are refreshed by webp_flush_webp_derivatives() or in webp_image_style_flush() if you are using the patch in 🐛 Saving media entities very slow after update to rc1 Needs work . The code looks for the derivative in the subdirectory but doesn't find it, so it doesn't get refreshed.

Steps to reproduce

In the image field settings configure a File directory where the image will be stored.
Change the image style, for example by changing the crop aspect ratio or the focal point.
Edit and save the media entity.
The webp derivative does not get updated.

Proposed resolution

We can solve the problem by storing the derivative in the same directory structure as the original file. To do that change the template in calls to getWebpDestination() to "@directory/@filename"

🐛 Bug report
Status

Closed: cannot reproduce

Version

1.0

Component

Code

Created by

🇪🇸Spain Peacog

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024