aelvan/Imager-Craft

(Why is) The cached transform not cleared @ EVENT_AFTER_DELETE_ELEMENT

renzo-s opened this issue · 2 comments

It seems like it should be a logical default to hook into Elements::EVENT_AFTER_DELETE_ELEMENT (and check for the Asset entry type) and erase the cached image, just like what happens when Assets::EVENT_AFTER_REPLACE_ASSET fires.

The reason the transforms are cleared (from the system path/cache) when replacing assets, is because new transforms for the new image wouldn't otherwise be created, since the filename is the same.

That issue is not relevant when deleting. But what I guess you allude to is that you expect Imager to deølete any transformed files if the original asset is deleted?

That was my reasoning indeed, the original ID would never be hit when the asset is deleted, so the folder should be removed with the contents to prevent a buildup of unused images.