dominus77/yii2-jcrop-widget

Jcrop Image Cropping Plugin for Yii2.

Installs: 4 974

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

v2.1.2 2020-02-17 07:37 UTC

This package is auto-updated.

Last update: 2024-11-17 20:09:57 UTC


README

Latest Version Software License Build Status codecov Scrutinizer Code Quality Total Downloads

Jcrop - Image Cropping for jQuery

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require dominus77/yii2-jcrop-widget

or add

"dominus77/yii2-jcrop-widget": "^2.1"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by mimimum run:

<?= \dominus77\jcrop\JCrop::widget([
    'image' => Yii::getAlias('@web/uploads/image1.jpg') // url to your image   
]) ?>

Set Options:

<?= \dominus77\jcrop\JCrop::widget([
    'image' => Yii::getAlias('@web/uploads/image1.jpg'),
    'pluginOptions' => [
        'minSize' => [50, 37],
        'maxSize' => [500, 370],
        'setSelect' => [10, 10, 40, 40],
        'bgColor' => 'black',
        'bgOpacity' => 0.5,
        'onSelect' => new yii\web\JsExpression("function(c){console.log(c.x);}"),
        'onChange' => new yii\web\JsExpression("function(c){console.log(c.x);}")
    ]
]) ?>

CallBack:

<?= \dominus77\jcrop\JCrop::widget([
    'image' => Yii::getAlias('@web/uploads/image1.jpg'),
    'pluginOptions' => [//...],
    'callBack' => new yii\web\JsExpression("
        function(){
            jcrop_api = this;
        }
    ")
]) ?>

More Information

Please, check the Manual

Testing

$ vendor/bin/phpunit

License

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