Delete entry assets? Is there a way to delete an entry's assets when the entry is deleted? We're going to end up with a lot of orphaned assets.

Or is this not a feature because an asset can be shared between entries? Thus requiring me to write a plugin to tie into the onDeleteEntry event (Where and how should you listen for entry delete in plugin?)?
This is how I did it:


In my custom plugin, in its init function, I use the following statement to hook into the before delete event: 

craft()-&gt;on('elements.onBeforeDeleteElements', array($this, 'beforeDeleteElements'));

In the same custom plugin, in the beforeDeleteElements function mentioned in step 1, I examine the passed in event, and determine if the entry type being deleted is the entry type I am interested in, if so, I use the following function to find the related assets and then delete them:

protected function deleteRelatedImages(EntryModel $entry)
{
    $criteria            = craft()-&gt;elements-&gt;getCriteria(ElementType::Asset);
    $criteria-&gt;relatedTo = $entry;
    $assets              = $criteria-&gt;find();

    if (!$assets) {
        return;
    }

    foreach ($assets as $asset) {
        $sourceType = $asset-&gt;getSource()-&gt;getSourceType();
        $sourceType-&gt;deleteFile($asset);
    }
}