-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear resized images on asset replace - good idea? #277
Comments
Hi, The Imager cache is actually supposed to be deleted when a file is replaced, so I'll have to check if there's a bug there if that wasn't happening for you. But, what OS is this on (or, where did you test and confirm that it was not deleted), and you're using the local "craft" transformer right? |
Hi, This is the setup where I tested: I did the following:
one more note: Both the source and the resized images are on an NFS share. To make sure, file permission are not the root of this problem, I su'ed into the user of the webserver and tried to delete such a directory on the console, this worked. |
Hi, I tested this, and transformed images are still deleted when replacing files. The folder you're looking at with the transformed images, does it contain the ID for the image? Ie, is it |
I just checked this and it is exactly as you describe it. AND it contains the ID. Would it be a good idea that you send me a filename and line where this magic happens so that I can simply do a quick I also again checked permissions, but they are 777 and owned by the webserver. |
Sure. The event listener that should get triggered is on line 241 in src/ImagerX.php. It runs removeTransformsForAsset() in src/services/ImagerService.php where the actual code is. I forgot to ask, did you check your logs for any errors? removeTransformsForAsset() should log various errors if it can't clear the directory. But first maybe try to establish if the event listener is triggered at all. Did you try disabling Blitz? Maybe we're listening for the same event and one of the plugins mucks it up for the other somehow? Shouldn't be an issue but worth checking. |
sorry for the delay, please keep this open |
I'm submitting a...
Steps to reproduce
Our editors just complained that when they do a "Assets > any image > replace file" with another asset with the same filename, the resized images do not get regenerated. I checked that and they are right, since the default transformation string does not respect a file's mtime.
So we now modify it in a config/imager-x.php to
'filenamePattern' => '{basename}_{transformString|hash}_{timestamp}.{extension}'
This does the job, but I was wondering if it is generally a good idea to keep resized images when the content of the file changes (or in other words, when someone replaces the file with a different binary). My initial idea would be to simply delete the folder which is named by the assets's ID in the resized image path, that would automatically clear all resized images of the replaced image binary.
My thoughts:
What are your thoughts on this?
The text was updated successfully, but these errors were encountered: