2017 © Pedro Peláez
 

yii2-extension yii2-widget-crop-image

Crop image input widget

image

evgkan/yii2-widget-crop-image

Crop image input widget

  • Wednesday, February 15, 2017
  • by evgkan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 77 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

yii2-widget-crop-image

This widget allows you to select a rectangular area on the source image on the server, cache the new image and use it., (*1)

Installation

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)

Use

In admin(profile) view:

<?= $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>
]

In model:

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)

In common view:

<img src="<?= model->photo ?>">       <!-- original photo -->
<img src="<?= model->cropPhoto ?>"> <!-- croped and cached photo -->

Warning!

The widget uses a serverside file manager mihaildev/yii2-elfinder. It needs to be properly configured to access the server file system., (*8)

The Versions

15/02 2017

dev-master

9999999-dev https://github.com/evgkan/yii2-widget-crop-image

Crop image input widget

  Sources   Download

MIT

The Requires

 

by Evgeny Kangin

yii2 widget image crop input