PHP code example of hustshenl / yii2-cropper

1. Go to this page and download the library: Download hustshenl/yii2-cropper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hustshenl / yii2-cropper example snippets


echo Form::widget([ // continuation fields to row above without labels
    'model' => $model,
    'form' => $form,
    'columns' => 1,
    'attributes' => [
        'cover' => [
            'type' => Form::INPUT_WIDGET,
            'widgetClass' => '\hustshenl\cropper\Cropper',
            'options' => [
                'data' => '',
                'pluginOptions' => [
                    'aspectRatio' => 240 / 320,
                    'autoCropArea' => 1,
                    'preview' => '.img-preview',
                    'strict' => true,
                    'guides' => false,
                    'highlight' => true,
                    'dragCrop' => true,
                    'cropBoxMovable' => true,
                    'cropBoxResizable' => true,
                ],
            ]
        ],
    ]
]);

$image = UploadedFile::getInstance($this, 'cover');
$cropper = $this->cover_crop