Skip to content

Commands ​

media-library:install ​

bash
php artisan media-library:install
OptionPurpose
--forceOverwrite the published config file.

Publishes config/filament-media-library.php, publishes Spatie's media-library config and create_media_table migration when they are missing, offers to run migrate, and links storage for the public disk. It ends with a list of next steps. See Installation.

media-library:import ​

bash
php artisan media-library:import spatie --model="App\Models\Post" --collection=gallery --folder="Imported" --dry-run
php artisan media-library:import curator --update=posts.cover_id --map=curator-map.json
php artisan media-library:import directory uploads/2024 --disk=s3
Argument or optionPurpose
sourcespatie, curator or directory.
pathDirectory source only. The directory to import, relative to the disk root.
--disk=Directory source only. Disk to read from. Defaults to the library disk.
--model=*Spatie only. Import media attached to these model classes. Repeatable.
--collection=*Spatie only. Import these collections. Repeatable.
--moveSpatie only. Delete the original Spatie media after copying it.
--table=curatorCurator only. The table that holds the media rows.
--update=*Curator only. Foreign key columns to rewrite to the new ids, as table.column. Repeatable.
--folder=Put everything in this folder. It is created when missing.
--map=Write a JSON map of old id to new library id to this file.
--tenant=Tenant key to assign to imported records.
--tenant-model=Tenant model class. Required with --tenant.
--dry-runCount what would be imported and write nothing. Add -v to list each file.

Imports are safe to repeat. Each record stores where it came from in custom_properties.imported_from, and files already imported are skipped. A file that fails is skipped with a warning and the run continues. The full walk-through is in Importing existing files.

media-library:regenerate ​

bash
php artisan media-library:regenerate --only=thumb --missing
OptionPurpose
--only=*Rebuild only these conversion names. Repeatable.
--missingBuild only conversions that do not exist yet.

Rebuilds conversions and responsive images for every file, with a progress bar. Run it after you change the conversions array in the config, or after you move files to a new disk. Conversions marked queued still go through your queue, so keep a worker running.

media-library:prune ​

bash
php artisan media-library:prune --days=14
OptionPurpose
--days=Delete trashed files older than this many days. Defaults to trash.prune_after_days (30).

Permanently deletes trashed files past the age limit, together with their attachments, and removes unfinished upload chunks older than 24 hours. It covers every tenant.

Scheduling ​

Schedule prune daily. Without it, abandoned chunks and old trash stay on disk.

php
// routes/console.php
use Illuminate\Support\Facades\Schedule;

Schedule::command('media-library:prune')->daily();

Keep regenerate out of the schedule. Run it by hand when conversions change.

Assets and translations ​

bash
php artisan filament:assets
php artisan vendor:publish --tag=filament-media-library-translations

Commercial licence. One licence per production project. Terms · Privacy · Refunds