Closed khalwat closed 6 years ago
Thanks @andris-sevcenko but (there's always a "but")...
In order to be able to find the proper transform sub-folder, we'd need to have $transformIndex
passed down too:
// Fire a 'deleteCreatedTransforms' event
if ($this->hasEventHandlers(self::EVENT_DELETE_ASSET_TRANSFORMS)) {
$this->trigger(self::EVENT_DELETE_ASSET_TRANSFORMS, new DeleteAssetTransformsEvent([
'asset' => $asset,
'transformIndex' => $transformIndex,
]));
...otherwise we won't be able to do:
...in the event handler (we'll have no idea what transformIndex
is associated with the passed down asset
).
@khalwat Just made some changes to the event(s). Let me know if it will work for you now.
@khalwat yeah for some reason I had assumed that nystudio107/craft3-imageoptimize
maintained it's own transform index and would know what files to get rid of. I'm not sure why, now.
It'd be wonderful if the
deleteCreatedTransformsForAsset()
fired anEVENT_DELETE_CREATED_TRANSFORMS
so that plugins that may have created image variants viaEVENT_GENERATE_TRANSFORM
have a chance to clean up after themselves.Specifically in my case, I create an
.webp
variant, and I'd like to clean it up if transforms are deleted as per:https://github.com/nystudio107/craft3-imageoptimize/issues/22