Download the PHP package devanderson/filament-media-gallery without Composer
On this page you can find all versions of the php package devanderson/filament-media-gallery. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devanderson/filament-media-gallery
More information about devanderson/filament-media-gallery
Files in devanderson/filament-media-gallery
Package filament-media-gallery
Short Description A comprehensive media gallery plugin for Filament with image editing, video support, and thumbnail generation.
License MIT
Homepage https://github.com/devanderson/filament-media-gallery
Informations about the package filament-media-gallery
Filament Media Gallery
A complete media gallery plugin for Filament v4 with support for image and video uploads, integrated image editor, automatic video thumbnail generation, and much more.
π Features
- β Image Uploads - Support for JPG, PNG, WebP, GIF
- β Video Uploads - Support for MP4, WebM, OGG
- β Image Editor - Integrated editor with Cropper.js
- β Video Thumbnails - Automatic generation using FFmpeg
- β Paginated Gallery - Intuitive and responsive interface
- β Dark Mode - Complete support for dark mode
- β Multiple Selections - Select one or multiple media items
- β Fully Configurable - Customize everything via config file
- β Internationalization - Support for multiple languages
π Requirements
- PHP 8.1 or higher
- Laravel 11.0 or higher
- Filament 4.0 or higher
- FFmpeg (optional, for video thumbnails)
π¦ Installation
1. Install via Composer
2. Publish Migrations
3. Publish Configuration (Optional)
π Basic Usage
Understanding the Component
The GalleryMediaField is a custom Filament form component designed to browse and select one or more media items (images or videos) from a pre-existing gallery. It stores the IDs of the selected media, which are then used to create a many-to-many relationship between your primary model and the media models (Image, Video) provided by the gallery package.
Step 1: Add the Component to Your Form
Add GalleryMediaField to your Filament form schema. You must specify the mediaType and a name for the field that will hold the selected IDs.
Field Configuration:
make('videos_ids'): Defines the field name that will hold an array of selected video IDs. Use a different name likeimages_idsfor images.mediaType('video'): Specifies the type of media to display in the gallery. Use'image'for images.allowMultiple(): Allows the user to select more than one item.
Step 2: Create Pivot Tables
A many-to-many relationship requires a "pivot" table to link your model with the media model. You need one pivot table for each media type you want to associate.
Image Pivot Table Migration
Video Pivot Table Migration
Step 3: Define Model Relationships
In your primary model, define the belongsToMany relationship for each media type. You must specify the custom pivot table name as the second argument.
Step 4: Integrate with Filament Resource Pages
To make the component work properly, you need to add logic to your Filament CreateRecord and EditRecord pages to handle saving and loading the relationship data.
Using the ProcessUploadGallery Trait
The package provides a convenient trait that handles all the synchronization logic:
CreateRecord Page:
EditRecord Page:
What the Trait Does:
afterCreatehook: Synchronizes the selected media IDs with the model relationships after creating a new recordafterSavehook: Synchronizes the selected media IDs when editing an existing record
Complete Form Example
π Advanced Usage Examples
Single Image Selection (Avatar, Cover, etc)
Limited Selection with Max Items
Video Gallery
βοΈ Configuration
The config/filament-media-gallery.php file offers various options:
π¬ FFmpeg Setup (Video Thumbnails)
To enable automatic thumbnail generation for videos, install FFmpeg:
Ubuntu/Debian
macOS
Windows
Download from: https://ffmpeg.org/download.html
Configure in .env
β οΈ Important Notes
Modal Forms Limitation
This implementation has been designed for use in standard Filament CreateRecord and EditRecord pages. It has not been tested within the context of modal forms (e.g., createOptionForm or editOptionForm inside a Select component). Using this component in modals may require additional adjustments to correctly handle the component's state and data flow.
Relationship Synchronization
The ProcessUploadGallery trait automatically handles the synchronization of media relationships. It:
- Extracts field names ending with
_idsfrom the form data - Converts field names to relationship names (e.g.,
videos_idsβvideos) - Syncs the selected IDs with the corresponding relationship
- Removes the temporary
_idsfields from the saved data
π Internationalization
The plugin includes translations for:
- π§π· Portuguese (pt_BR)
- πΊπΈ English (en)
To add new translations:
π§ͺ Testing
π Changelog
See CHANGELOG for more information about recent changes.
π€ Contributing
Contributions are welcome! See CONTRIBUTING for details.
π Security
If you discover security issues, please email [email protected].
π License
The MIT License (MIT). See License File for more information.
π Credits
- Anderson Nascimento dos Santos
- Filament
- Cropper.js
- FFmpeg
- All Contributors
π‘ Support
- π Documentation
- π Issues
- π¬ Discussions
All versions of filament-media-gallery with dependencies
filament/forms Version ^4.0
spatie/laravel-package-tools Version ^1.15.0
filament/filament Version ^4.0
intervention/image Version ^2.7