maxmirazh33/yii2-uploadable-cropable-image Yii2 extension for upload and crop images

extensionimagejcropimageuploadimagecrop

Yii2 uploadable and cropable image

Yii2 extension for upload and crop images

Latest Version Software License Quality Score Total Downloads

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist maxmirazh33/yii2-uploadable-cropable-image "*"

or add

"maxmirazh33/yii2-uploadable-cropable-image": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

In your model:

public function behaviors()
{
    return [
        [
            'class' => \maxmirazh33\image\Behavior::className(),
            'savePathAlias' => '@web/images/',
            'urlPrefix' => '/images/',
            'crop' => true,
            'attributes' => [
                'avatar' => [
                    'savePathAlias' => '@web/images/avatars/',
                    'urlPrefix' => '/images/avatars/',
                    'width' => 100,
                    'height' => 100,
                ],
                'logo' => [
                    'crop' => false,
                    'thumbnails' => [
                        'mini' => [
                            'width' => 50,
                        ],
                    ],
                ],
            ],
        ],
    //other behaviors
    ];
}

Use rules for validate attribute.

In your view file:

echo $form->field($model, 'avatar')->widget('maxmirazh33\image\Widget');

After, in your view:

echo Html::img($model->getImageUrl('avatar'));
echo Html::img($model->getImageUrl('logo', 'mini')); //get url of thumbnail named 'mini' for 'logo' attribute

If you use Advanced App Template and this behavior attached in backend model, then in frontend model add trait

use \maxmirazh33\image\GetImageUrlTrait

and use getImageUrl() method for frontend model too.

Changelog

Changelog

All Notable changes to yii2-uploadable-cropable-image will be documented in this file

2.2.6

  • Use asset-packagist instead of global fxp composer plugin

2.2.5

  • Fix jcrop package name for compatibility with composer 2.0

2.2.4

  • Move Jcrop to bower dependency

2.2.3

2.2.2

  • Fix issues #3, #4

2.2.1

  • Fix issue #2

2.2.0

  • Changed extension skeleton

2.1.1

  • Improved GetImageUrlTrait

2.1.0

  • Added GetImageUrlTrait

2.0.2

  • Refactored Behavior
  • Better definition savePathAlias and urlPrefix

2.0.1

  • Fixed coords input name

2.0.0

  • Deleted validator adding in behavior

1.0.3

  • Added validatorOptions property
  • Fixed bugs delete files
  • Fixed client validation bug

1.0.2

  • Allowed use attribute without options array

1.0.1

  • Fixed image uploader
  • Added badges

1.0.0

  • Initial release

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



v2.2.5 is the latest of 15 releases



MIT license
Stats
9 github stars & 9 github forks
10 downloads in the last day
155 downloads in the last 30 days
16626 total downloads