2017 © Pedro Peláez
 

yii2-extension yii2-crop-image-upload

Yii 2 Crop image upload widget

image

karpoff/yii2-crop-image-upload

Yii 2 Crop image upload widget

  • Friday, November 13, 2015
  • by karpoff
  • Repository
  • 7 Watchers
  • 19 Stars
  • 7,055 Installations
  • JavaScript
  • 6 Dependents
  • 0 Suggesters
  • 17 Forks
  • 12 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

cropped image upload extension for Yii2

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

This extension automatically uploads image and make crop., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist karpoff/yii2-crop-image-upload "*"

or add, (*5)

"karpoff/yii2-crop-image-upload": "*"

to the require section of your composer.json file., (*6)

Usage

Upload image and create crop

Attach the behavior in your model:, (*7)

use karpoff\icrop\CropImageUploadBehavior;

class Document extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            ['photo', 'file', 'extensions' => 'jpeg, gif, png', 'on' => ['insert', 'update']],
        ];
    }

    /**
     * @inheritdoc
     */
    function behaviors()
    {
        return [
            [
                'class' => CropImageUploadBehavior::className(),
                'attribute' => 'photo',
                'scenarios' => ['insert', 'update'],
                'path' => '@webroot/upload/docs',
                'url' => '@web/upload/docs',
                'ratio' => 1,
                'crop_field' => 'photo_crop',
                'cropped_field' => 'photo_cropped',
            ],
        ];
    }
}

Example view file:, (*8)



 ['enctype' => 'multipart/form-data']]); ?>
    <?= $form->field($model, 'photo')->widget(CropImageUpload::className()) ?>
    <div class="form-group">
        <?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
    </div>

The Versions

13/11 2015

dev-master

9999999-dev https://github.com/karpoff/yii2-crop-image-upload

Yii 2 Crop image upload widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Karpov

yii2 upload image crop

15/12 2014

0.0.1

0.0.1.0 https://github.com/karpoff/yii2-crop-image-upload

Yii 2 Crop image upload widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Karpov

yii2 upload image crop