Problem/Motivation
When applying this conversion processor into the optimization pipeline and if you have focalpoint/crop modules and if you have image that has the focalpoint enable and if you go into that existing image and update the focalpoint the derivative image are not being refresh .
Basically when you upgrade your Focalpoint settings for an existing images the new image derivates are not being regenerate , because the implementation of the hook_image_style_flush, the implantation of this hook is not being executed because the crop module sends the path parameter for the `image_path_flush()` functions ,which results in the not execution of our hook_image_style_flush, because there is `if` into that core function that prevent us to reach the execution of our hook, so, the old images styles are not being deleted and new ones are not being generated because of this issue with the Crop module
Steps to reproduce
steps to reproduce:
- Create a imagepi pipeline (configure it as global)
- add to that Pipeline the WebP processor
- now Add the Resmush.it processor
- Save your config
- Now go to any existing node with a media field, update the image focalpoint .
- Now go to your node FE , you should be able to see your image , But as you can see your new focal point is not being generated , the old image stills in placed
Proposed resolution
I'm Creating a new submodule call: imageapi_optimize_webp_crop, in that I make use of a entity update to trigger the images style generation post the crop entity update.
I think this is also related to this issue:
https://www.drupal.org/project/imageapi_optimize_webp/issues/3213379 , and since the core solution still needing work, opening this ticket
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | imageapi-optimize-webp.png | 318.69 KB | franckylfs |
Issue fork imageapi_optimize_webp-3362476
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
Comment #3
rigoucrSwitching status to needs review, I provided the possible solution for this issue , as you can see into the Merge request , this provides a new submodule `imageapi_optimize_webp_crop`, so , to test this , go into the merge request, extract the patch from it , apply it into your code and enable the new submodule.
Why a submodule,? well when the core issues that it's related to this is done , you could easily remove this from the code base .
Comment #4
ccjjmartin commented@rigoucr I would consider removing the reference to Drupal 8 compatibility in the module (if you choose to keep it). I am not sure if the submodule was intended to be kept permanently or if it was for easy testing but it seems like this one hook could be placed into the module itself? Looking at the code it looks like we have a "crop" module that has a "crop" entity and when the crop entity is updated the image style isn't flushed?
Comment #5
rigoucrHi @ccjjmartin thank you for your feedback, I did it in that way because I thought that in that will be easier to remove in the future (this is a tmp solution for the real issue ) , but you made me think about about it and I'm changing the approach , I'm moving the code into the main .module file , that will be easier for the maintainer to remove this code later when is not longer need it .
And to answer your question , yes , the image styles are not being flushed when the crop entity gets updated .
Comment #6
franckylfs commentedHi @rigoucr, I got this error when I updated a focal point.
Looking at the image styles, I saw that one of them didn't use any image optimization pipeline. Logically, this shouldn't be a problem since it's optional as explained in the description under the field: "Optionally select an Image Optimization pipeline which will be applied after all effects in this image style".
So looking at the code I saw that it could be fixed quickly just by adding a validation to check if $pipeline is empty or not just before this line:
$processors = $pipeline->getProcessors();What do you think?
Comment #7
dieterholvoet commentedCrop::postSavedoesn't always flush image styles:Instead of duplicating their logic I propose hooking into the general
hook_image_style_flushinstead. Doing it that way would also fix other potential issues when flushing image styles in other ways, like throughdrush image:flush. I'll try that out now.Comment #8
dieterholvoet commentedWorks perfectly! I also fixed the issue that was mentioned in #6.
Comment #9
dieterholvoet commentedComment #10
dieterholvoet commentedThis seems to be a duplicate of #3213379: WebP images are not regenerated when using image_widget_crop. To be honest, the fix there is a lot simpler and more performant, so I think we should close this in favour of that one.