matteomascellani/filament-preview-files 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

matteomascellani/filament-preview-files

最新稳定版本:v1.0.2

Composer 安装命令:

composer require matteomascellani/filament-preview-files

包简介

Reusable Filament actions and views for file and ticket previews

README 文档

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

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固