hustshenl/yii2-cropper

增强型 Yii2 包装器,用于 Cropper jQuery 插件(从 yii2-widgets 分离的子存储库)。

安装: 54

依赖: 1

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

语言:JavaScript

类型:yii2-extension

0.1.2 2020-01-10 05:01 UTC

This package is auto-updated.

Last update: 2024-09-10 14:49:02 UTC


README

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads

安装

安装此扩展的首选方式是通过 composer。请查看此扩展的 composer.json 以了解其要求和依赖项。阅读有关为您的应用程序的 composer.json 设置 minimum-stability 的此 网络提示 /wiki

要安装,请运行以下之一:

$ php composer.phar require hustshenl/yii2-widget-cropper "@dev"

或将其添加到您的 composer.json 文件的 require 部分:

"hustshenl/yii2-widget-cropper": "@dev"

使用

使用方法

在视图中

echo Form::widget([ // continuation fields to row above without labels
    'model' => $model,
    'form' => $form,
    'columns' => 1,
    'attributes' => [
        'cover' => [
            'type' => Form::INPUT_WIDGET,
            'widgetClass' => '\hustshenl\cropper\Cropper',
            'options' => [
                'data' => '',
                'pluginOptions' => [
                    'aspectRatio' => 240 / 320,
                    'autoCropArea' => 1,
                    'preview' => '.img-preview',
                    'strict' => true,
                    'guides' => false,
                    'highlight' => true,
                    'dragCrop' => true,
                    'cropBoxMovable' => true,
                    'cropBoxResizable' => true,
                ],
            ]
        ],
    ]
]);

在模型中

$image = UploadedFile::getInstance($this, 'cover');
$cropper = $this->cover_crop

许可协议

yii2-widget-cropper 采用 BSD 3-Clause 许可协议发布。有关详细信息,请参阅附带 LICENSE.md