Imager-Craft icon indicating copy to clipboard operation
Imager-Craft copied to clipboard

(Why is) The cached transform not cleared @ EVENT_AFTER_DELETE_ELEMENT

Open ghost opened this issue 5 years ago • 2 comments
trafficstars

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.

ghost avatar Jan 06 '20 11:01 ghost

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?

aelvan avatar Jan 06 '20 21:01 aelvan

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.

Renzo-S avatar Jan 06 '20 21:01 Renzo-S