Skip to content

When an asset is deleted

Sends a notification when an Asset has been deleted.

This trigger fires for both soft deletes (moved to the trash) and hard deletes. Restoring a deleted asset fires the separate "When an asset is restored" event.

Volume Filters

Choose which asset volumes should fire this notification. Only assets stored in the selected volumes will trigger it.

Selection is required

Check at least one volume, or the notification won't fire.

Field Conditions

Field conditions restrict the notification based on the element's content, using Craft's native conditions framework. Build a rule set against the element's attributes and field values, and the notification will be sent only when every rule matches.

Must match all conditions

The condition builder evaluates every rule with AND semantics, so each rule must pass for the notification to be sent.

Twig variables

The object variable (and its asset alias) is the deleted Asset.

twig
{{ asset.filename }} was just deleted from "{{ asset.volume.name }}".

Examples

Alert moderators when an asset is removed

twig
{{ currentUser.fullName }} deleted an asset:

- File: {{ asset.filename }}
- Volume: {{ asset.volume.name }}
- Folder: {{ asset.folder.name }}
- Size: {{ asset.size|filesize }}

Only announce deletions from a watched volume

twig
{% if asset.volume.handle != 'criticalDocuments' %}
    {% skipMessage "Only Critical Documents trigger this announcement." %}
{% endif %}

Deleted from Critical Documents: {{ asset.filename }}.

Notify the asset's uploader

twig
{% if asset.uploader is null %}
    {% skipMessage "No uploader on record." %}
{% endif %}

Hi {{ asset.uploader.firstName }},

The file you uploaded, "{{ asset.filename }}", was just deleted by {{ currentUser.fullName }}.