dev-master
9999999-devYii2 crop image widget
The Requires
- php >=5.4.0
- yiisoft/yii2 *
- yiisoft/yii2-imagine *
- yurkinx/yii2-image *
yii2 upload image crop cutter
Yii2 crop image widget
This is a fork Patroklo//yii2-image-cutter, (*1)
, (*2)
The preferred way to install this extension is through Composer., (*3)
Either run php composer.phar require --prefer-dist mitrm/yii2-image-cutter "dev-master"
, (*4)
or add "mitrm/yii2-image-cutter": "dev-master"
to the require section of your composer.json
, (*5)
use mitrm\cutter\behaviors\CutterBehavior; public function behaviors() { return [ 'image' => [ 'class' => CutterBehavior::className(), 'attributes' => 'image', 'baseDir' => '/uploads/crop', 'basePath' => '@webroot', ], ] } public function rules() { return [ ['image', 'file', 'extensions' => 'jpg, jpeg, png', 'mimeTypes' => 'image/jpeg, image/png'], ]; }
attributes
required (string) - Image attributesbaseDir
required - Base directorybasePath
required - Base pathinteger quality
= 92
- Crop result quality, (*6)
Use in view, (*7)
Without client validation, (*8)
<div class="form-group"> <label class="control-label">Image</label> <?= \mitrm\cutter\Cutter::widget([ 'model' => $model, 'attribute' => 'image' ]); ?> </div>
or, (*9)
With client validation, (*10)
<?= $form->field($model, 'image')->widget(\mitrm\cutter\Cutter::className(), [ //options ]); ?>
Get url to image, (*11)
$model->getImg(100); $model-> getImgOrigin();
model (string) (obligatory), (*12)
Defines the model that will be used to make the form input field., (*13)
attribute (string) (obligatory), (*14)
Defines the model attribute that will be used to make de form input field., (*15)
useWindowHeight (bool) (optional), (*16)
Use the height of the current window for the form image cropping, (*17)
imageOptions (array) (optional), (*18)
List with options that will be added to the image field that will be used to define the crop data in the modal. The format should be ['option' => 'value']., (*19)
cropperOptions (array) (optional), (*20)
List with options that will be added in javaScript while creating the crop object. For more information about which options can be added you can read this web., (*21)
Yii2 crop image widget
yii2 upload image crop cutter