matteomascellani/filament-preview-files

Reusable Filament actions and views for file and ticket previews

Maintainers

Package info

github.com/matteomascellani/filament-preview-files

Language:Blade

pkg:composer/matteomascellani/filament-preview-files

Statistics

Installs: 12

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2026-03-15 10:23 UTC

This package is auto-updated.

Last update: 2026-04-16 12:16:21 UTC


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 from 1.x
  • publish v2.* tags from 2.x