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

  1. Install the ImageAPI Optimize module.
  2. Add a pipeline (e.g., WebP/Avif conversion, compression, etc.).
  3. Create an image style using this pipeline.
  4. Render imagecache_external images using the created image style.
  5. Remove the external media.
  6. 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.

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

anna d created an issue. See original summary.

anna d’s picture

Status: Active » Needs review

One 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.

swentel’s picture

Hook makes sense! Tests failures seem unrelated, I'll check them during the weekend to see what's going on there.

  • swentel committed 433a6c55 on 3.0.x authored by anna d
    #3557909: Added alter hook to allow overriding derivative filenames
    
swentel’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

swentel’s picture

Status: Fixed » Closed (fixed)

Merged in, thanks! Will release soon after I merge two other issues.