steirico / kirby-plugin-image-crop-field

Kirby image crop field based on vue-cropperjs and gumlet/php-image-resize
MIT License
15 stars 3 forks source link

deleting an image not deleting its cropped version #30

Closed Joscha95 closed 2 years ago

Joscha95 commented 2 years ago

As the title says: I think one would expect, that when the image is deleted, its cropped version also gets removed. But that does not seem to happen imo.

A hook like this would be required i think (this only works if your cropped images have a specific template):

'hooks' => [ 'file.delete:before' => function ($file) { if ($file->intendedTemplate()=='cover') { $file->croppedImage()->delete(); } } ]

this could also work (not tested):

'hooks' => [ 'file.delete:before' => function ($file) { if ($file->croppedImage()) { $file->croppedImage()->delete(); } } ]