yii2-illustrated-behavior ActiveRecord behavior + associated widget

  1. Requirements
  2. Usage of Illustrated
  3. Usage of Uploader
  4. Resources

Illustrated is a Behavior that makes any ActiveRecord, well, illustrated. It links the ActiveRecord to one (or possibly more) image files. The images have strict proportions, allowing for a clean layout of views and other pages. The uploaded images may have several resolutions.

The Illustrated behavior co-operates with the enclosed Uploader widget. This lets the user crop the image by dragging and zooming it, before uploading it to the server.

Requirements

Yii 2.0

Usage of Illustrated

Illustrated is used like any Behavior of an ActiveRecord. The code should look something like this:

class <model> extends \yii\db\ActiveRecord { 
    ... 
    public function behaviors(){
        return [
            [
                "class" => "sjaakp\illustrated\Illustrated",
                ...     // Illustrated options
            ],
            ...     // other behaviors
        ];
    }
    ...
}

Usage of Uploader

Uploader is an input widget. It can be used in an ActiveForm like this:

use sjaakp\illustrated\Uploader;

<?php $form = ActiveForm::begin([
        'options' => ['enctype' => 'multipart/form-data']   // important, needed for file upload
    ]); ?>

    ...     // other form fields

    <?= $form->field($model, 'file')->widget(Uploader::className(), [
           ...      // Uploader options
        ]) ?>

    ...

<?php ActiveForm::end(); ?>

Resources

1 0
6 followers
251 downloads
Yii Version: 2.0
License: MIT
Category: Others
Developed by: Sjaakp
Created on: Jul 25, 2014
Last updated: 9 years ago

Downloads

show all

Related Extensions