定制 r64/nova-image-cropper 二次开发

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

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

r64/nova-image-cropper

最新稳定版本:1.1.5

Composer 安装命令:

composer require r64/nova-image-cropper

包简介

A Laravel Nova field.

README 文档

README

This field extends Image Field adding a handy cropper to manipulate images. Can be configurable in the same way as a File field in Nova.

Demo

Demo

Install

Run this command into your nova project: composer require r64/nova-image-cropper

Add it to your Nova Resource:

use R64\NovaImageCropper\ImageCropper;

ImageCropper::make('Photo'),

Update form

In order to edit the existing image saved in the model, ImageCroper uses the preview method to return a base64 encoded image. You can either use the default implementation or override it as long as you return a base64 image.

use R64\NovaImageCropper\ImageCropper;

ImageCropper::make('Photo')
        ->preview(function () {
            if (!$this->value) return null;

            $url = Storage::disk($this->disk)->url($this->value);
            $filetype = pathinfo($url)['extension'];
            return 'data:image/' . $filetype . ';base64,' . base64_encode(file_get_contents($url));
        });

Options

Avatar mode

You can add a rounded mask to the preview and the cropper

ImageCropper::make('Photo')->avatar()

Custom aspect ratio

Define the fixed aspect ratio of the crop box.

  • Type: Number
  • Default: NaN
ImageCropper::make('Photo')->aspectRatio(16/9)

For free ratio use:

ImageCropper::make('Photo')->aspectRatio(0)

Localization

Set your translations in the corresponding xx.json file located in /resources/lang/vendor/nova

...

  "Edit Image": "Editar Imagen",
  "Cancel Crop": "Cancelar Recorte",
  "Change Image": "Cambiar Imagen",
  "Done": "Hecho",
  "Click here or drop the file to upload": "Click aquí o arrastra el archivo para comenzar la subida"

统计信息

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

GitHub 信息

  • Stars: 56
  • Watchers: 1
  • Forks: 16
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-31