marshmallow/nova-advanced-image 问题修复 & 功能扩展

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

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

marshmallow/nova-advanced-image

Composer 安装命令:

composer require marshmallow/nova-advanced-image

包简介

An advanced image field for Nova with crop and resize.

README 文档

README

alt text

Nova Advanced Image Field

Latest Version on Packagist Tests Total Downloads

An advanced image field for Nova with crop and resize.

This package provides an advanced image field for Nova resources allowing you to upload, crop and resize any image. It uses Cropper.js with vue-cropperjs in the frontend and Intervention Image in the backend.

screenshot of the advanced image field

Requirements

Intervention Image requires one of the following libraries for image processing:

  • GD Library >=2.0 (used by default)
  • Imagick PHP extension >=6.5.7

See the Intervention requirements for more details. The autoOrientate() helper additionally requires the PHP exif extension to be enabled.

Installation

Install the package into a Laravel application with Nova using Composer:

composer require marshmallow/nova-advanced-image

The field service provider is auto-discovered, so there is nothing further to register.

If you want to use Imagick as the default image processing library, follow the Intervention documentation for Laravel. This will provide you with a new configuration file where you can specify the driver you want. You can also override the driver per field with ->driver('imagick').

Usage

AdvancedImage extends Nova's Image field, so you can use any method that Image/File implements. See the Nova file field documentation for the inherited options.

<?php

namespace App\Nova;

// ...
use Marshmallow\AdvancedImage\AdvancedImage;

class Post extends Resource
{
    // ...

    public function fields(Request $request)
    {
        return [
            // ...

            // Simple image upload
            AdvancedImage::make('photo'),

            // Show a cropbox with a free ratio
            AdvancedImage::make('photo')->croppable(),

            // Show a cropbox with a fixed ratio
            AdvancedImage::make('photo')->croppable(16 / 9),

            // Resize the image to a max width
            AdvancedImage::make('photo')->resize(1920),

            // Resize the image to a max height
            AdvancedImage::make('photo')->resize(null, 1080),

            // Show a cropbox and resize the image
            AdvancedImage::make('photo')->croppable()->resize(400, 300),

            // Auto-rotate based on the image's Exif orientation (requires the exif extension)
            AdvancedImage::make('photo')->autoOrientate(),

            // Override the image processing driver for this field only ('gd' or 'imagick')
            AdvancedImage::make('photo')->driver('imagick')->croppable(),

            // Store to AWS S3
            AdvancedImage::make('photo')->disk('s3'),

            // Specify a custom subdirectory
            AdvancedImage::make('photo')->disk('s3')->path('image'),
        ];
    }
}

The resize option uses Intervention Image resize() with the upsize and aspect ratio constraints.

Available methods

Method Description
croppable($param = true) Enable the crop box. Pass a numeric value (e.g. 16 / 9) to lock a fixed aspect ratio.
resize($width = null, $height = null) Resize the stored image to a maximum width and/or height.
driver(string $driver) Override the Intervention driver for this field. Accepts gd or imagick.
autoOrientate() Rotate the image to the orientation stored in its Exif data. Requires the PHP exif extension.
customThumbnail($callable) Customise the thumbnail URL resolver (proxies Nova's thumbnail()).
customPreview($callable) Customise the preview URL resolver (proxies Nova's preview()).
setCustomCallback($customCallback) Run a custom callback after the image has been stored.

Avatar variant

For avatar-style fields, use AdvancedAvatar. It extends AdvancedImage, implements Nova's Cover contract and renders a rounded thumbnail.

use Marshmallow\AdvancedImage\AdvancedAvatar;

AdvancedAvatar::make('avatar')->croppable(1),

Security

If you discover any security related issues, please email stef@marshmallow.dev instead of using the issue tracker.

Changelog

Please see CHANGELOG for recent changes.

Credits

License

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

marshmallow/nova-advanced-image 适用场景与选型建议

marshmallow/nova-advanced-image 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 65.48k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 07 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 marshmallow/nova-advanced-image 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 9
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-17