teamnovu/statamic-unused-assets

Addon to list all assets not in use on your Statamic dashboard.

v2.0.2 2024-05-14 08:04 UTC

This package is auto-updated.

Last update: 2024-11-14 09:11:51 UTC


README

This is an addon to list all assets that are not used in your statamic site.

Features

This addon adds a widget which you can add to your dashboard. If there are assets which are currently not in use on your sites they will be listed in that widget.

How to Install

Run the following command in your project root:

composer require teamnovu/statamic-unused-assets

How to Use

Just add the widget to your config/statamic/cp.php as you would any other widget.

The following is an example which shows all the possible config values you can use.

'widgets' => [
    // ...

        [
            'type' => 'unused-assets', // Required
            'limit' => 300, // Default: 300 – The number of images to display from the widget.
            'width' => 100, // Default: 100 – The size of the widget.
            'excluded_paths' => [], // Example: ['assets/myFolder/'] - Default: [] – The paths to exclude from the search.
        ],
],

Note This widget caches the assets displayed forever and updates the cache when events such as AssetDeleted, AssetSaved AssetUploaded EntryDeleted, EntrySaved TermDeleted, TermSaved GlobalSetDeleted, GlobalSetSaved are fired.

Development

This addon workers due to the potential heavy workload. To test the addon localy a queue worker needs to be running e.g.

php artisan queue:listen

Credit

This widget has basically been extracted from the Statamic Peak starter kit updated with inspiration from Swiftmade Statamic Clear Assets