system.assets.beforeAddAsset

Triggered in: System\Traits\AssetMaker.php

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;
});

Keep informed

Sign up to our newsletter to receive updates on Winter CMS releases, new features in the works, and much more.
We'll never spam or give this address away.

Latest blog post

The Winter CMS Web Installer is now available!

Published June 17, 2021
We are super excited to announce that our new Web-based Installer is finally available for download, to make it super easy to get your next Winter CMS project started!

View this post Read all posts

Latest Winter CMS release

v1.1.3

Released April 26, 2021
3 UX/UI Improvements, 19 API Changes, 23 Bug Fixes, 3 Security Improvements, 4 Translation Improvements, 1 Community Improvement, 2 Dependencies

View details View all releases