GitHub - insane-dev/yii2-crop-image-upload: Yii2 extension for cropped image upload | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

insane-dev/yii2-crop-image-upload

 
 

Repository files navigation

cropped image upload extension for Yii2

Latest Stable Version Total Downloads Latest Unstable Version License

This extension automatically uploads image and make crop.

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your composer.json file.

Usage

Upload image and create crop

Attach the behavior in your model:

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:

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

About

Yii2 extension for cropped image upload

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 81.4%
  • PHP 14.2%
  • CSS 4.4%

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.