imsyuan/filament-image-caption-upload 问题修复 & 功能扩展

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

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

imsyuan/filament-image-caption-upload

最新稳定版本:1.0.0

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 License

A Filament v3 form component that extends FileUpload to attach a per-image caption to each uploaded file.

Database Format

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

[
  { "image": "photos/abc.jpg", "caption": "Living room view" },
  { "image": "photos/def.jpg", "caption": "Kitchen detail" }
]

Requirements

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

Installation

composer require imsyuan/filament-image-caption-upload

Usage

use Imsyuan\ImageCaptionUpload\Forms\Components\ImageCaptionUpload;

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

Cast the model attribute as an array:

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

Options

captionPlaceholder(string|Closure $placeholder)

Sets the placeholder text shown inside each caption input. Defaults to 'Caption...'.

All FileUpload options

ImageCaptionUpload extends Filament's built-in FileUpload, so all existing options work as-is: ->image(), ->multiple(), ->maxFiles(), ->reorderable(), ->panelLayout(), ->disk(), ->directory(), etc.

How it works

  1. Hydration[{image, caption}] is split: paths go to Filament's normal UUID-keyed state; captions are stored in a sibling Livewire key (_icap_<fieldname>).
  2. Alpine — A MutationObserver watches for FilePond item additions and injects caption <input> elements beneath each file panel. Captions are entangled back to Livewire state.
  3. UUID cache — FilePond internal IDs are mapped to Filament UUIDs so captions survive reorders and upload race conditions.
  4. Dehydration{uuid: path} and {uuid: caption} are zipped back into [{image, caption}] before saving.

License

MIT — see LICENSE.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固