Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Spatie Laravel Media Library Plugin

Spatie Laravel Media Library Plugin Laravel Package

filament/spatie-laravel-media-library-plugin

Filament plugin integrating Spatie Laravel Media Library. Adds a SpatieMediaLibraryFileUpload form field with the same API as Filament’s FileUpload, supporting media collections and configurable disks, while storing uploads via the Media Library.

View on GitHub
Deep Wiki
Context7

[READ ONLY] Subtree split of the Filament spatie/laravel-medialibrary Plugin (see filamentphp/filament)

Frequently asked questions about Spatie Laravel Media Library Plugin
How do I integrate this plugin into an existing Filament admin panel?
Install via Composer (`filament/spatie-laravel-media-library-plugin`), publish Spatie’s migrations, and run them. Then use `SpatieMediaLibraryFileUpload` in your Filament forms like the native `FileUpload` component. No extra JS or CSS is needed—it works out-of-the-box with Filament’s UI.
Does this plugin support custom storage disks like S3 or Wasabi?
Yes, it inherits Spatie’s disk flexibility. Use the `disk()` method on the field (e.g., `->disk('s3')`) or configure collections to use specific disks via Spatie’s config. Filament’s default disk setting is ignored unless overridden per field.
Can I use media collections (e.g., 'avatars', 'documents') with this plugin?
Absolutely. Pass a `collection()` name to the field (e.g., `->collection('avatars')`), then define the collection in Spatie’s config with disk/directory rules. Collections let you organize media logically and apply per-collection storage settings.
Will this work with Laravel 9/10 and Filament v2.5+?
The plugin targets Laravel 8+ and Filament v2+. For Laravel 9/10, ensure you’re on `^5.0` of the plugin, which aligns with Spatie’s latest versions. Check the [Filament compatibility table](https://filamentphp.com/docs/installation#laravel-versions) for minor version quirks.
How do I add media fields to Filament tables or resources?
Use `SpatieMediaLibraryFileUpload` in forms or `SpatieMediaLibraryTableColumn` in tables. For resources, define the field in your `Form` or `Table` classes. Example: `SpatieMediaLibraryTableColumn::make('media')->collection('images')` for displaying media in a table.
Does this plugin handle file transformations (e.g., thumbnails, resizing)?
Yes, it leverages Spatie’s `convert()` and `convertImmediately()` methods. Define transformations in Spatie’s config (e.g., `thumbnails`, `video_thumbnails`) and they’ll apply automatically when files are uploaded via the plugin’s field.
What if I already use `spatie/laravel-medialibrary` but not Filament?
The plugin adds zero overhead if you’re already using Spatie’s package. It simply wraps the media library in Filament’s UI components. No migrations or model changes are needed—just install the plugin and replace native file uploads with `SpatieMediaLibraryFileUpload`.
How do I customize the media upload UI (e.g., allowed file types, preview size)?
Use Filament’s built-in methods like `->acceptedFileTypes(['jpg', 'png'])`, `->maxSize(1024)`, or `->previewMode('contain')`. For advanced tweaks, override the plugin’s Blade views or use Filament’s `modify` methods to inject custom JS/CSS.
Can I use this for bulk media uploads or drag-and-drop in Filament?
Yes, the plugin supports drag-and-drop via Filament’s native `FileUpload` base. For bulk actions, use Spatie’s `Media` model methods (e.g., `delete()`, `each()`) in Filament’s `Table` actions or custom widgets. Pagination is handled automatically for large collections.
Are there performance concerns with thousands of media files?
For large libraries, enable Spatie’s `lazy-loading` or `server-side processing` via config. The plugin itself doesn’t add significant overhead, but complex queries (e.g., `withMetadata`) may need optimization. Test with `DB::enableQueryLog()` to identify slow queries.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity