dominus77 / yii2-jcrop-widget
Jcrop Image Cropping Plugin for Yii2.
Installs: 5 004
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- bower-asset/jcrop: ^2.0
- yiisoft/yii2: ~2.0
Requires (Dev)
- phpunit/phpunit: 6.*
- roave/security-advisories: dev-master
README
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.