dev-master
9999999-dev https://github.com/evgkan/yii2-widget-crop-imageCrop image input widget
MIT
The Requires
- php >=5.4.0
- yiisoft/yii2 *
- mihaildev/yii2-elfinder *
by Evgeny Kangin
yii2 widget image crop input
Crop image input widget
This widget allows you to select a rectangular area on the source image on the server, cache the new image and use it., (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist evgkan/yii2-widget-crop-image "*"
or add, (*4)
"evgkan/yii2-widget-crop-image": "*"
to the require section of your composer.json
file., (*5)
<?= $form->field($model, 'photo')->widget(CropImage::className()) ?>
After you submit the form the model attribute will contain an array with the data framing, like this:, (*6)
[ 'imgSrc' => <path>, 'x1' => <left 0..1>, 'y1' => <top 0..1>, 'x2' => <right 0..1>, 'y2' => <bottom 0..1> ]
public function getCropPhoto(){ return CropImage::getCropImage($this->photo); }
This method searches the cached image, using data framing. If cached image is absent, a new one is created., (*7)
<img src="<?= model->photo ?>"> <!-- original photo --> <img src="<?= model->cropPhoto ?>"> <!-- croped and cached photo -->
The widget uses a serverside file manager mihaildev/yii2-elfinder. It needs to be properly configured to access the server file system., (*8)
Crop image input widget
MIT
yii2 widget image crop input