matteomascellani / filament-preview-files
Reusable Filament actions and views for file and ticket previews
Package info
github.com/matteomascellani/filament-preview-files
Language:Blade
pkg:composer/matteomascellani/filament-preview-files
Requires
- php: ^8.2
- filament/filament: ^3.2
- illuminate/support: ^11.0
README
Reusable Filament v4 actions and Blade views for:
- media zoom preview (images and PDF)
- media open in new tab
- graceful fallback when URL is missing (red unavailable icon)
Requirements
- Filament
^4.0 - Spatie Media Library
^11.0 - Laravel
^11.28|^12.0 - PHP
^8.2
Install
From Packagist (recommended)
composer require matteomascellani/filament-preview-files
From local path (development)
Add to root composer.json:
{
"repositories": [
{
"type": "path",
"url": "packages/matteomascellani/filament-preview-files"
}
]
}
Then require the package:
composer require matteomascellani/filament-preview-files:*
Service Provider
The package uses Laravel auto-discovery via extra.laravel.providers, so in normal setups you do not need to register the provider manually.
If your project disables package discovery, register manually:
Matteomascellani\FilamentPreviewFiles\FilamentPreviewFilesServiceProvider::class,
Optional: publish config.
php artisan vendor:publish --tag=filament-preview-files-config
Usage
1) Use in a Filament table (Actions)
use Matteomascellani\FilamentPreviewFiles\Actions\MediaPreviewAction; use Matteomascellani\FilamentPreviewFiles\Actions\MediaOpenAction; use Matteomascellani\FilamentPreviewFiles\Actions\MediaZoomAction; use Matteomascellani\FilamentPreviewFiles\Actions\MediaUnavailableAction;
->recordActions([ // Wrapper that injects all table actions: // - zoom (only for image/pdf with valid URL) // - open in new tab (only with valid URL) // - unavailable fallback (red no-symbol when URL is missing) ...MediaPreviewAction::make( urlResolver: fn ($record) => $record->getUrl(), mimeResolver: fn ($record) => (string) $record->mime_type, ), ])
If you prefer separate actions, all single actions are still available:
->recordActions([ MediaZoomAction::make( urlResolver: fn ($record) => $record->getUrl(), mimeResolver: fn ($record) => (string) $record->mime_type, ), MediaOpenAction::make( urlResolver: fn ($record) => $record->getUrl(), ), MediaUnavailableAction::make( urlResolver: fn ($record) => $record->getUrl(), ), ])
2) Use in a normal Blade view
You can include the package views directly, even outside Filament table actions.
Media zoom modal content:
@include('filament-preview-files::modals.media-zoom-content', [ 'url' => $url, 'mimeType' => $mimeType, 'label' => $label, ])
Helper component-like partial for link + zoom trigger:
@include('filament-preview-files::components.media-zoom-link', [ 'url' => $url, 'mimeType' => $mimeType, 'label' => $label, ])
Current Usage In This Project
app/Filament/Resources/System/MediaResource.php...MediaPreviewAction::make(...)in table actions
Branching And Versioning
1.x: Filament 3 compatible line (Laravel 11)2.x: Filament 4 compatible line
Suggested release policy:
- publish
v1.*tags from1.x - publish
v2.*tags from2.x