Set aspect ratio and crop size
Demo of Illustrated

Note: as this is a demo, you can't really upload files. However, you can browse for images on your system and test the Uploader widget.


In this case, the aspect ratio (width/height) is set to 1.778 (16/9), and the crop size to 600.

In the database, only the field with the file name of the cropped image is stored.

Data in the database

Click on the thumbnail to see the img file(s) on the server.

nameimgaspect
Fire fight3apbyb.jpg

Configuration of the model

<?php

class <model> extends \yii\db\ActiveRecord
{
    ...
    public function behaviors()    {
        return [
            [
                'class' => 'sjaakp\illustrated\Illustrated',
                'attributes' => [
                    'img' => [
                        'aspectRatio' => 1.778,
                        'cropSize' => 600
                    ]
                ]
            ],
            ...        // other behaviors
        ];
    }
    ...
}

Settings for the Uploader widget

<?php
use sjaakp\illustrated\Uploader;
?>

<?php $form = ActiveForm::begin([
    'options' => ['enctype' => 'multipart/form-data']    // important, needed for file upload
]); ?>
    ...        // other form fields
<?= $form->field($model, 'img')->widget(Uploader::className(), [
        'deleteOptions' => false    // suppress rendering of delete checkbox
    ]) ?>
    ...
<?php ActiveForm::end(); ?>