Delete files related to entry


I have a media field on a content type. When that content type is deleted, I want to delete the related media file as well.

I thought, well, let’s hook into beforeDelete but that is only triggered when the entry is deleted from the detail page in the backend. When doing a many delete (from the collection type list view), this is not triggered.

One other approach I had was to use and find files with a specific field, but there is no specific field for the relation to the collection type entry it seems?

So where do I go now?