system.assets.beforeAddAsset
Triggered in System\Traits\AssetMaker.
Provides an opportunity to inspect or modify an asset.
The parameters provided are:
string $type: The type of the asset being added
string $path: The path to the asset being added
array $attributes: The array of attributes for the asset being added.
All the parameters are provided by reference for modification. This event is also a halting event, so returning false will prevent the current asset from being added. Note that duplicates are filtered out before the event is fired.
Example usage:
Event::listen('system.assets.beforeAddAsset', function (string $type, string $path, array $attributes) {
if (in_array($path, $blockedAssets)) {
return false;
}
});
Or
$this->bindEvent('assets.beforeAddAsset', function (string $type, string $path, array $attributes) {
$attributes['special_cdn_flag'] = false;
});