定制 imsyuan/filament-image-caption-upload 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

imsyuan/filament-image-caption-upload

Composer 安装命令:

composer require imsyuan/filament-image-caption-upload

包简介

Filament v3 FileUpload component with per-image caption support

README 文档

README

Latest Version on Packagist GitHub Tests Action Status PHPStan License

English | 繁體中文

A Filament v3 form component that extends the built-in FileUpload to attach a per-image caption beneath each uploaded file — with no build step required.

Demo

Features

  • Drop-in replacement — extends Filament's native FileUpload, so every existing option (->image(), ->multiple(), ->reorderable(), ->disk(), ->directory(), ->maxFiles(), …) works unchanged
  • Zero build step — no npm, no Vite, no esbuild; pure Blade + Alpine.js inline
  • Reorder-safe — captions follow their image through drag-and-drop reordering
  • Duplicate-filename safe — maps FilePond internal IDs to Filament UUIDs directly, so ten files all named banner.jpg each keep their own caption
  • Race-condition safe — captions typed before an upload finishes are preserved and migrated to the final UUID automatically
  • Simple storage — saved as a plain [{image, caption}] JSON array in a single column; no extra tables or relationships needed

Requirements

  • PHP 8.2+
  • Laravel 10+
  • Filament 3.x

Installation

Choose the version that matches your Filament installation:

Filament Version
3.x ^1.0
4.x ^2.0
5.x ^3.0
# Filament 3.x
composer require imsyuan/filament-image-caption-upload "^1.0"

# Filament 4.x
composer require imsyuan/filament-image-caption-upload "^2.0"

# Filament 5.x
composer require imsyuan/filament-image-caption-upload "^3.0"

Laravel auto-discovers the service provider — no manual registration needed.

Usage

use Imsyuan\ImageCaptionUpload\Forms\Components\ImageCaptionUpload;

ImageCaptionUpload::make('photos')
    ->multiple()
    ->image()
    ->reorderable()
    ->captionPlaceholder('Enter a caption…'),

Cast the column as an array in your model:

// app/Models/Post.php
protected $casts = [
    'photos' => 'array',
];

Each field saves an array of {image, caption} pairs:

[
  { "image": "photos/living-room.jpg", "caption": "Living room view" },
  { "image": "photos/kitchen.jpg",     "caption": "Kitchen detail" }
]

Options

captionPlaceholder(string|Closure $placeholder)

Sets the placeholder text shown inside each caption input. Accepts a plain string or a closure. Defaults to 'Caption...'.

// Static
->captionPlaceholder('Add a description…')

// Dynamic
->captionPlaceholder(fn () => __('fields.caption_placeholder'))

All native FileUpload options

Because ImageCaptionUpload extends Filament's FileUpload directly, every built-in option is available:

ImageCaptionUpload::make('photos')
    ->multiple()
    ->image()
    ->maxFiles(10)
    ->reorderable()
    ->appendFiles()
    ->disk('s3')
    ->directory('photos')
    ->visibility('public')
    ->panelLayout('grid')
    ->imageResizeMode('cover')
    ->imageResizeTargetWidth('400')
    ->imageResizeTargetHeight('400'),

How it works

  1. Hydration[{image, caption}] from the database is split on load: file paths go into Filament's UUID-keyed state; captions are stored in a sibling Livewire key (_icap_<fieldname>).
  2. Alpine — A MutationObserver watches for FilePond item additions and injects a caption <input> beneath each file panel. Typing syncs directly to Livewire state via $wire.set().
  3. UUID mapping — FilePond's internal IDs are mapped to Filament UUIDs by reading the FilePond instance directly (pond.getFiles()), ensuring correctness regardless of stored filename or UUID-based disk naming.
  4. Dehydration — On save, {uuid: path} and {uuid: caption} are zipped back into [{image, caption}].

License

MIT — see LICENSE.

imsyuan/filament-image-caption-upload 适用场景与选型建议

imsyuan/filament-image-caption-upload 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「image」 「laravel」 「file-upload」 「caption」 「filament」 「filamentphp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 imsyuan/filament-image-caption-upload 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 imsyuan/filament-image-caption-upload 我们能提供哪些服务?
定制开发 / 二次开发

基于 imsyuan/filament-image-caption-upload 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-10