hustshenl/yii2-cropper

Enhanced Yii2 wrapper for the Cropper jQuery plugin (sub repo split from yii2-widgets).

Installs: 54

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Language:JavaScript

Type:yii2-extension

0.1.2 2020-01-10 05:01 UTC

This package is auto-updated.

Last update: 2024-04-10 13:57:13 UTC


README

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads

Installation

The preferred way to install this extension is through composer. Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json.

To install, either run

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

or add

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

to the require section of your composer.json file.

Usage

In View

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,
                ],
            ]
        ],
    ]
]);

In Model

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

License

yii2-widget-cropper is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.