Edit on GitHub

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;


$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


Released August 25, 2021
1 Bug Fix

View details View all releases