---
title: "Artisan commands — Media Library for Laravel | Roundly"
description: "Regenerate variants, clean orphaned files, clear buckets, verify checksums and prune expired drafts."
url: https://roundly-consulting.com/open-source/docs/media-library-for-laravel/commands
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Media Library for Laravel](https://roundly-consulting.com/open-source/docs/media-library-for-laravel.md)

# Artisan commands

Five maintenance commands cover variants, cleanup, integrity and drafts:

```bash
# Regenerate image variants. Optionally filter by model type or ids, limit to named
# variants with --only, and force regeneration of already-generated variants with --force.
php artisan media:regenerate
php artisan media:regenerate "App\Models\User" --ids=1,2,3 --only=thumb,display --force

# Remove orphaned variant files (files in a media's own variants directory it no longer
# records). Conservative: it never touches soft-deleted media, never removes a file any row
# stores as its original, and skips a variants directory the layout shares between media.
php artisan media:clean

# Clear a bucket — delete every media (row + files) in it. Omit the model for global media.
# A model class is mapped through your morph map, so the class name and its alias both work.
php artisan media:clear "App\Models\User" avatar
php artisan media:clear "" brand

# Verify stored media against their checksum baselines; exits non-zero on any failure.
php artisan media:verify
php artisan media:verify "App\Models\User" --ids=1,2,3

# Prune expired, never-bound draft media (rows + files). Schedule this if you use drafts.
php artisan media:prune-drafts
```

- media:regenerate — rebuild variants and responsive widths (e.g. after changing a bucket's variant definitions); the same work as MediaLibrary::regenerate().
- media:clean — remove orphaned variant/width files left behind by definition changes. It never touches soft-deleted media, never removes a file any row stores as its original, and skips a variants directory the layout shares between media.
- media:clear — delete every media (row + files) in a model or global bucket. The model class is mapped through your morph map, so the class name and its alias both work; unbound drafts are left alone.
- media:verify — check stored originals against their checksums, each with the algorithm that took it; useful after disk migrations or to catch bit-rot.
- media:prune-drafts — the same as MediaLibrary::pruneDrafts(); it only touches owner-less drafts, never one moved to an owner. Schedule it if you use drafts.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/media-library-for-laravel.md)
