antoinecorbin / filament-advanced-spatie-media-library
Allows you to manage media translations with Spatie Translatable and Filament repeater support.
1.0.0
2025-02-07 17:32 UTC
Requires
- php: ^8.1
- filament/spatie-laravel-media-library-plugin: ^3.2
- illuminate/support: ^10.45|^11.0
- spatie/laravel-medialibrary: ^10.0|^11.0
README
This package extends the functionality of the Filament Spatie Media Library plugin by adding support for translations with Spatie Translatable and compatibility with Filament repeaters.
Installation
You can install the package via composer:
composer require antoinecorbin/filament-advanced-spatie-media-library
Configuration
The package works automatically without additional configuration. It uses the existing Spatie Media Library configuration.
Usage
Basic Usage
use AntoineCorbin\Form\Components\AdvancedMediaLibraryFileUpload; AdvancedMediaLibraryFileUpload::make('media')
With Translations
To use translations, your model must use Spatie's HasTranslations
trait:
use Spatie\Translatable\HasTranslations; class Post extends Model { use HasTranslations; public array $translatable = ['media']; }
In a Repeater
The component works automatically within a Filament repeater:
Repeater::make('sections') ->schema([ AdvancedMediaLibraryFileUpload::make('images') ])
Features
- Full translation support with Spatie Translatable
- Smart media management in repeaters
- Automatic abandoned file cleanup
- Repeater index updates
- Multiple collection support
- Image manipulation compatibility
- Responsive images support
Advanced Usage
The component automatically handles:
- File uploads and organization within repeater fields
- Translation management for multilingual media
- Media collection management
- Custom properties preservation
- Automatic cleanup of unused media
Available Methods
AdvancedMediaLibraryFileUpload::make('media') ->collection('images') // Set a specific media collection ->multiple() // Allow multiple file uploads ->responsiveImages() // Enable responsive images ->customProperties([]) // Add custom properties to media ->withManipulations([]) // Add image manipulations
License
The MIT License (MIT). Please see License File for more information.