Problem/Motivation
When using imagecache_external with ImageAPI Optimize pipelines, derivative images generated by these pipelines are not deleted when the source external media is removed. Standard derivatives are deleted correctly, but those created by ImageAPI Optimize remain, causing orphaned files and unnecessary storage usage.
Steps to reproduce
- Install the ImageAPI Optimize module.
- Add a pipeline (e.g., WebP/Avif conversion, compression, etc.).
- Create an image style using this pipeline.
- Render imagecache_external images using the created image style.
- Remove the external media.
- Run cron or flush imagecache_external.
Observed result: Standard external image derivatives are removed, but ImageAPI Optimize derivatives remain.
Expected result: All derivatives, including those created by ImageAPI Optimize pipelines, are deleted when the source external media is removed.
Issue fork imagecache_external-3557909
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
anna d commentedOne way to handle it is to check if the imageapi_optimize module exists, load its pipelines, and add the derivative extensions directly, but that couples the code to the module’s internal structure.
A more flexible approach seems to be using an alter hook (hook_imagecache_external_flush_filepath_alter), which lets any module adjust the list of file paths to delete. This feels safer and more extensible for different setups, without depending on a specific module.
Comment #4
swentel commentedHook makes sense! Tests failures seem unrelated, I'll check them during the weekend to see what's going on there.
Comment #6
swentel commentedComment #8
swentel commentedMerged in, thanks! Will release soon after I merge two other issues.