2017 © Pedro Peláez
 

yii2-extension yii2-image-cutter

Yii2 crop image widget

image

sadovojav/yii2-image-cutter

Yii2 crop image widget

  • Monday, February 20, 2017
  • by sadovojav
  • Repository
  • 6 Watchers
  • 7 Stars
  • 2,401 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 2 Open issues
  • 2 Versions
  • 16 % Grown

The README.md

Yii2 image cutter

This is a fork Patroklo/yii2-widget-upload-crop, (*1)

Features:

  • Upload image
  • Crop image
  • Use Imagine
  • Cache sorting to subdirectories

cutter, (*2)

Composer

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

Either run php composer.phar require sadovojav/yii2-image-cutter "dev-master", (*4)

or add "sadovojav/yii2-image-cutter": "dev-master" to the require section of your composer.json, (*5)

Use

  • Add to the model behavior
    use sadovojav\cutter\behaviors\CutterBehavior;

    public function behaviors()
    {
        return [
            'image' => [
                'class' => CutterBehavior::className(),
                'attributes' => 'image',
                // 'attributes' => ['image1', 'image2'],
                'baseDir' => '/uploads/crop',
                'basePath' => '@webroot',
            ],
        ]
    }

    public function rules()
    {
        return [
            ['image', 'file', 'extensions' => 'jpg, jpeg, png', 'mimeTypes' => 'image/jpeg, image/png'],
        ];
    }

Parameters

  • integer attributes required (string/array) - Image attributes
  • integer baseDir required - Base directory
  • integer basePath required - Base path
  • integer quality = 92 - Crop result quality, (*6)

  • Use in view, (*7)

    Without client validation, (*8)

    <div class="form-group">
        <label class="control-label">Image</label>
        <?= \sadovojav\cutter\Cutter::widget([
            'model' => $model,
            'attribute' => 'image'
        ]); ?>
    </div>

or, (*9)

With client validation, (*10)

    <?= $form->field($model, 'image')->widget(\sadovojav\cutter\Cutter::className(), [
        //options
    ]); ?>

Widget method options

  • model (string) (obligatory), (*11)

    Defines the model that will be used to make the form input field., (*12)

  • attribute (string) (obligatory), (*13)

    Defines the model attribute that will be used to make de form input field., (*14)

  • useWindowHeight (bool) (optional), (*15)

    Use the height of the current window for the form image cropping, (*16)

  • imageOptions (array) (optional), (*17)

    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']., (*18)

  • cropperOptions (array) (optional), (*19)

    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., (*20)

The Versions

20/02 2017

dev-master

9999999-dev

Yii2 crop image widget

  Sources   Download

The Requires

 

yii2 upload image crop cutter

12/06 2015

1.0.0.0

1.0.0.0

Crop image widget.

  Sources   Download

The Requires

 

yii2 upload image crop cutter