ahmed-abdelrhman/filament-media-gallery
Filament infolist entry for Spatie Media Library collections: renders a responsive media grid with an Alpine.js fullscreen lightbox for images and proper PDF cards that open in a new tab. Type-aware, no extra dependencies, works with Filament 3–5.
Pros:
Infolist, Section). Leverages Filament’s bundled Alpine.js and Tailwind, eliminating external dependencies.MediaLibraryImageEntry.MediaGalleryEntry component is designed for easy integration into any Filament resource or custom page via Blade components.aspect-square and dark mode support out of the box, reducing custom CSS/JS requirements.thumbnail > preview > original) for faster grid rendering, while the lightbox loads high-res originals.Cons:
Infolist contexts; standalone usage (e.g., in custom Filament pages) requires manual Blade component integration, which may not be as seamless.HasMedia typically mitigates this).fromRelation() usage could lead to runtime errors if the relation or collection doesn’t exist. Requires careful validation in visible() closures (e.g., $record->relation?->getMedia()->isNotEmpty()).fromRelation() thoroughly with edge cases (e.g., missing relations).thumbnail conversions are properly configured (e.g., width(150)->nonQueued()).SpatieMediaLibraryImageEntry usages in Filament resources.SpatieMediaLibraryImageEntry with MediaGalleryEntry in a non-critical resource (e.g., a test PageResource).fromRelation).User → Profile).SpatieMediaLibraryImageEntry instances in resources.registerMediaConversions() to include thumbnail/preview for optimal performance.php artisan vendor:publish --tag=media-gallery-views) for tailored templates.<x-media-gallery-viewer>) for standalone usage.HasMedia methods).HasMedia/InteractsWithMedia on relevant models.registerMediaConversions() for thumbnail/preview optimizations.composer require ahmed-abdelrhman/filament-media-gallery).SpatieMediaLibraryImageEntry with MediaGalleryEntry in infolist() methods.fromRelation() for nested media.x-show="...").| Failure Scenario | Impact | Mitigation |
|---|---|---|
Missing thumbnail conversion |
Broken image placeholders | Ensure registerMediaConversions() includes thumbnail. |
Incorrect fromRelation() usage |
MethodNotFoundException |
Validate relations in visible() closures. |
| Alpine.js conflicts | Lightbox fails to initialize | Check Filament’s bundled Alpine.js version. |
| Large media collections | Slow grid rendering | Add client-side pagination or limit collection size. |
| PDF handling issues | PDFs render as broken images | Verify Spatie Media Library’s MIME type detection. |
| Dark mode styling bugs | UI inconsistencies in dark mode | Test with Filament’s dark mode toggle. |
How can I help you explore Laravel packages today?