Flush derivatives for an updated image

Created on 14 February 2023, almost 2 years ago

Problem/Motivation

When an image is updated (replace file, or edit focal point) and triggers an image style flush, the dynamic derivatives generated by this module should be deleted.

Proposed resolution

Attached patch adds a hook_image_style_flush() to remove the generated derivatives. NB requires a core patch to pass the image path to the hook ( https://www.drupal.org/project/drupal/issues/2833129 🐛 hook_image_style_flush doesn't get the $path passed to Drupal\image\Entity\ImageStyle::flush() method Fixed ).

Remaining tasks

The regex pattern to target only derivatives generated by this module (any image styles with a '[' in the path) wasn't working with FileSystem::scanDirectory() - so all derivatives for the given image are deleted (even those generated by core's image styles).

💬 Support request
Status

Needs review

Version

1.0

Component

Code

Created by

🇨🇦Canada bgilhome Victoria

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

Comments & Activities

Production build 0.71.5 2024