chocoway/moonshine-compressed-image 问题修复 & 功能扩展

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

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

chocoway/moonshine-compressed-image

最新稳定版本:v1.0.0

Composer 安装命令:

composer require chocoway/moonshine-compressed-image

包简介

Compressed Image field for MoonShine

README 文档

README

A custom image field for MoonShine admin panel with built-in image compression, resizing, thumbnail generation and format conversion powered by Intervention Image v3.

Requirements

  • PHP 8.2+
  • Laravel 10|11|12
  • MoonShine 4.x
  • GD extension

Installation

composer require chocoway/moonshine-compressed-image

Usage

use Chocoway\MoonshineCompressedImage\Fields\CompressedImage;

CompressedImage::make('Photo', 'photo')
    ->width(1000)
    ->height(800)
    ->aspectRatio()
    ->format('webp')
    ->quality(80)
    ->thumb(200, 200)

Available Methods

Method Description
->width(int $width) Set max width in pixels
->height(int $height) Set max height in pixels
->aspectRatio() Keep aspect ratio when resizing
->format(string $format) Output format: jpg, png, webp, gif
->quality(int $quality) Compression quality from 1 to 100 (default: 80)
->thumb(int $width, int $height) Generate a thumbnail alongside the original

Examples

Resize with aspect ratio (recommended):

CompressedImage::make('Photo', 'photo')
    ->width(1000)
    ->aspectRatio()
    ->format('webp')
    ->quality(80)

With thumbnail:

CompressedImage::make('Photo', 'photo')
    ->width(1000)
    ->aspectRatio()
    ->format('webp')
    ->quality(80)
    ->thumb(200, 200)

Thumbnail is saved alongside the original with a thumb_ prefix:

  • Original: images/photo.webp
  • Thumbnail: images/thumb_photo.webp

Convert to WebP without resizing:

CompressedImage::make('Photo', 'photo')
    ->format('webp')
    ->quality(75)

Strict resize to exact dimensions:

CompressedImage::make('Photo', 'photo')
    ->width(1000)
    ->height(500)
    ->format('jpg')
    ->quality(90)

Compatibility

CompressedImage extends the standard MoonShine Image field, so all built-in File and Image methods are fully supported:

CompressedImage::make('Photo', 'photo')
    ->width(1000)
    ->format('webp')
    ->quality(80)
    ->disk('s3')               // custom filesystem disk
    ->dir('uploads/photos')    // storage subdirectory
    ->multiple()               // upload multiple images
    ->removable()              // allow deleting images
    ->keepOriginalFileName()   // preserve original filename

See the MoonShine docs for the full list of available File and Image methods.

License

MIT

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固