haosheng0211/filament-media-browser
Composer 安装命令:
composer require haosheng0211/filament-media-browser
包简介
A standalone Filament v3 media browser powered by Laravel Storage — no database required.
README 文档
README
A standalone Filament v3 media browser powered by Laravel Storage — no database required. Browse, upload, and manage files directly from the filesystem with folder navigation support.
Features
- Browse files and folders on any Laravel Storage disk
- Upload, delete files and create/delete folders
- Breadcrumb navigation with subfolder support
- Filter by media type (image, video/audio, or all files)
- Search files by name
- Filename sanitization and collision handling
- Path traversal protection
- Authentication guard on all operations
- Dark mode support
- Works with any Filament v3 panel or Livewire component
Installation
composer require haosheng0211/filament-media-browser
Publish the config file:
php artisan vendor:publish --tag="filament-media-browser-config"
Add the package views to your tailwind.config.js content array:
// tailwind.config.js content: [ // ...existing paths './vendor/haosheng0211/filament-media-browser/resources/views/**/*.blade.php', ]
Then rebuild your assets:
npm run build
Make sure the storage disk is linked (for the public disk):
php artisan storage:link
Configuration
// config/filament-media-browser.php return [ // Laravel filesystem disk 'disk' => 'public', // Root directory for browsing 'directory' => 'media', // Allowed upload MIME types 'accepted_file_types' => ['image/*', 'video/*', 'audio/*'], // Max upload size in KB 'max_file_size' => 10240, // Output format: true = Storage::url(), false = relative path 'store_as_url' => true, ];
Usage
MediaPicker Field
A dedicated form field with square card previews, replace and remove buttons. Both single and multiple modes use the same grid layout with 1:1 aspect ratio cards. Stores the selected file's URL as a string (single) or array of strings (multiple) by default.
use MrJin\FilamentMediaBrowser\Forms\Components\MediaPicker; // Basic usage — single image picker with preview MediaPicker::make('featured_image'); // Multiple images (gallery) MediaPicker::make('gallery') ->multiple() ->maxItems(10) ->reorderable(); // drag-to-reorder, enabled by default // File picker (no image preview, shows path instead) MediaPicker::make('attachment') ->mediaType('file'); // Custom disk and directory MediaPicker::make('hero_image') ->mediaDisk('s3') ->mediaDirectory('uploads/heroes'); // Store relative path instead of URL MediaPicker::make('document') ->storePath(); // Custom grid columns (default: 5, fewer = larger cards) MediaPicker::make('hero') ->gridColumns(3);
Stored value:
- Single mode: string (e.g.
/storage/media/photo.jpg) — use astringcolumn - Multiple mode: array of strings — use a
jsoncolumn with->cast('array')on the model - Default output is
Storage::url()(full URL). Use->storePath()to store the relative path (e.g.media/photo.jpg) instead.
Available Methods
| Method | Description |
|---|---|
->multiple(bool) |
Enable multi-select mode |
->maxItems(int) |
Maximum number of files (multiple mode) |
->reorderable(bool) |
Enable drag-to-reorder (multiple mode, default: true) |
->mediaType(string) |
'image' (default), 'media', or 'file' |
->mediaDisk(string) |
Override config disk |
->mediaDirectory(string) |
Override config directory |
->storeAsUrl(bool) |
Store as Storage::url() output (default: true) |
->storePath(bool) |
Store as relative path (e.g. media/photo.jpg) |
->gridColumns(int) |
Number of columns in the preview grid (default: 5) |
With Filament Forms TinyMCE
This package works seamlessly with filament-forms-tinymce. Once both packages are installed, TinyMCE's file picker will automatically use the media browser.
use MrJin\FilamentFormsTinymce\TinyMceEditor; TinyMceEditor::make('content'); // With custom disk/directory per field TinyMceEditor::make('content') ->mediaDisk('s3') ->mediaDirectory('uploads/posts'); // Disable the file browser TinyMceEditor::make('content') ->fileBrowser(false);
Standalone Usage via Events
The media browser communicates via Livewire events, so you can integrate it with any component.
Open the browser by dispatching the open-media-browser event:
// From Livewire — single file $this->dispatch('open-media-browser', statePath: 'data.image', mediaType: 'image'); // Multiple files with custom disk/directory $this->dispatch('open-media-browser', statePath: 'data.files', mediaType: 'file', multiple: true, disk: 's3', directory: 'uploads', ); // Store relative path instead of URL $this->dispatch('open-media-browser', statePath: 'data.document', mediaType: 'file', storeAsUrl: false, );
<!-- From Alpine.js --> <button x-on:click="Livewire.dispatch('open-media-browser', { statePath: 'data.image', mediaType: 'image', })"> Browse Media </button>
Listen for file selection via the media-selected event:
// Livewire #[On('media-selected')] public function onMediaSelected( string $statePath, string $url, string $alt, string $title, string $filename, string $extension, int $size, string $mime, ): void { // Use the selected media URL and metadata }
<!-- Alpine.js --> <div x-on:media-selected.window="handleMedia($event.detail)">
Event Reference
| Event | Direction | Parameters |
|---|---|---|
open-media-browser |
You → Browser | statePath, mediaType (image | media | file), multiple?, disk?, directory?, storeAsUrl? |
media-selected |
Browser → You | statePath, url, alt, title, filename, extension, size, mime |
Media Types
| Value | Filters |
|---|---|
image |
image/* only |
media |
video/* and audio/* |
file |
All files (no filter) |
Customizing Views
php artisan vendor:publish --tag="filament-media-browser-views"
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
haosheng0211/filament-media-browser 适用场景与选型建议
haosheng0211/filament-media-browser 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「file-browser」 「filament」 「media-browser」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 haosheng0211/filament-media-browser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 haosheng0211/filament-media-browser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 haosheng0211/filament-media-browser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A storage directory tree view with file management for Laravel applications.
Alfabank REST API integration
Symfony bundle for entity-based file browser and management.
Database-driven onboarding for Filament: progress checklists and guided spotlight tours, translatable to any locale.
A modern, web-based file manager with advanced features like bulk operations, archive handling, and path-based navigation
FileManager plugin for BakeKit
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-15