承接 michaeld555/filament-croppie 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

michaeld555/filament-croppie

Composer 安装命令:

composer require michaeld555/filament-croppie

包简介

Croppie Js Implementation Field for Filament forms

README 文档

README

Latest Version on Packagist Total Downloads

This package provides an image cropping component for FilamentPHP, using the Croppie.js library. It allows users to interactively crop images before uploading, offering flexible configuration options to control the crop size, aspect ratio, and format.

filament croppie

Installation

composer require michaeld555/filament-croppie

After installation, you'll be prompted to publish the configuration file and translations. It's recommended to publish the configuration file to customize the default options.

php artisan vendor:publish --tag="filament-croppie-config"

You can also run the install command to publish the config and translations

php artisan filament-croppie:install

Configuration

The configuration file config/filament-croppie.php allows you to customize the behavior of the Croppie modal. The available options are:

Option Description Default Value
title Modal title. 'Manage Image'
description Modal description. 'Crop the image to the correct proportion'
icon Modal icon (optional). null
size Modal size (e.g., sm, md, lg, xl, 2xl, 3xl, 4xl, etc.). 4xl
boundary-height Height of the crop boundary area. 400
boundary-width Width of the crop boundary area. 600
viewport-height Height of the visible crop area (viewport). 200
viewport-width Width of the visible crop area (viewport). 200
enable-resize Enables resizing of the viewport. false
enable-zoom Enables zooming on the image. true
show-zoomer Shows the zoom control. true
viewport-type Type of viewport (circle or square). circle

Usage

To use the Croppie component in a Filament form, simply instantiate the Michaeld555\FilamentCroppie\Components\Croppie component:

use Michaeld555\FilamentCroppie\Components\Croppie;

Croppie::make('avatar')
    ->label('Avatar') // Field label
    ->disk('public') // Storage disk
    ->directory('avatars') // Storage directory
    // ... other configuration options

Examples

Basic Usage with Custom Upload Path

Croppie::make('profile_picture')
    ->label('Profile Picture')
    ->disk('s3')
    ->directory('profile-images')
    ->imageResizeTargetWidth(400)
    ->imageResizeTargetHeight(400);

Circular Crop (Avatar) with Larger Modal

Croppie::make('user_avatar')
    ->avatar()
    ->modalSize('5xl')
    ->modalDescription('Please upload a square image for optimal results.');

Screenshot of basic croppie

Square Crop with Custom Viewport Size and Zoom Disabled

Croppie::make('product_image')
    ->viewportType('square')
    ->viewportHeight(250)
    ->viewportWidth(250)
    ->enableZoom(false)
    ->imageFormat('webp');

Screenshot of basic croppie

Croppie Component Methods

  • modalTitle(string | Closure | null $modalTitle): Sets the modal title.
  • modalDescription(string | Closure | null $modalDescription): Sets the modal description.
  • modalIcon(string | Closure | null $modalIcon): Sets the modal icon.
  • modalSize(string | Closure | null $modalSize): Sets the modal size.
  • customClasses(string | Closure | null $customClasses): Sets custom CSS classes for the Croppie container.
  • enableOrientation(bool | Closure | null $enableOrientation): Enables/disables image orientation detection.
  • enableResize(bool | Closure | null $enableResize): Enables/disables viewport resizing.
  • enableZoom(bool | Closure | null $enableZoom): Enables/disables zoom on the image.
  • enforceBoundary(bool | Closure | null $enforceBoundary): Sets whether the image should be forced to stay within the defined boundary.
  • mouseWheelZoom(bool | Closure | string $mouseWheelZoom): Sets the mouse wheel zoom behavior (true, false, or 'ctrl').
  • showZoomer(bool | Closure | null $showZoomer): Sets whether the zoom control should be displayed.
  • forceCircleResult(bool | Closure | null $forceCircleResult): Sets whether the crop result should be forced to a circle.
  • viewportType(string | Closure | null $viewportType): Sets the viewport type ('circle' or 'square').
  • viewportHeight(string | Closure | null $viewportHeight): Sets the viewport height.
  • viewportWidth(string | Closure | null $viewportWidth): Sets the viewport width.
  • boundaryHeight(string | Closure | null $boundaryHeight): Sets the boundary height.
  • boundaryWidth(string | Closure | null $boundaryWidth): Sets the boundary width.
  • imageFormat(string | Closure | null $imageFormat): Sets the resulting image format (e.g., 'png', 'jpeg', 'webp').
  • imageSize(string | Closure | null $imageSize): Sets the resulting image size ('viewport' or 'original').
  • imageName(string | Closure | null $imageName): Allows customizing the image name. By default, a UUID is used.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

michaeld555/filament-croppie 适用场景与选型建议

michaeld555/filament-croppie 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 3.59k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2024 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 michaeld555/filament-croppie 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 2
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-13