Yii2 Illustrated

The Illustrated behavior makes an 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, before uploading it to the server.

GitHub: github.com/sjaakp/yii2-illustrated-behavior.

Demos: www.sjaakpriester.nl/software/illustrated.

Seems just what I was looking for … I’ll give it a try soon.

Maybe you should consider adding this intresting extension to the Yii Extension section so it is more visible.

Good Job

ciao

B)

I don’t know why but for me don’t upload the image.

profile model:




class Profile extends \yii\db\ActiveRecord

{


	    /**

     * @inheritdoc

     */

    public function behaviors()    

    {

         return [

	     	[

		 	"class" => "sjaakp\illustrated\Illustrated", 

		 	]

		 ];

     }

     

     

    public static function tableName()

    {

        return 'profile';

    }




in controller:




    public function actionAvatar()

    { 

    		

        $model = new Profile();

        return $this->render('avatar', [

                'model' => $model,

            ]);

     }



in view:




 <?

            $form = ActiveForm::begin([

				'options' => ['enctype' => 'multipart/form-data']	// important, needed for file upload

			]); ?>

			

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

				   'stylefileOptions' => [

					'btnClass' => 'btn btn-success',

					'btnText' => 'Upload image'

				   ],

				   'cropperOptions' => [

					'diagonal' => 240,

					'margin' => 12,

					'sliderPosition' => 'right',

					'sliderOptions' => [

					     'animate' => 'slow'

					]

				   ]

				]) 

			?>

			


                <div class="form-group">

                    <div class="col-lg-offset-3 col-lg-9">

                        <?= \yii\helpers\Html::submitButton(Yii::t('user', 'Save'), ['class' => 'btn btn-success']) ?><br>

                    </div>

                </div>

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




in illustrated.php


   public $illustrationDirectory = 'images';

my folder: web/images/profile or web/images/avatar.

Where I wrong? :(

hi, Install library imagick in php.

Hello; Thanks for sharing. From the doc on github that I read there are some options that the extension has and I don’t really understand their usage well; so :

I have an model to which I want like to attach more than 2 images(each image must be stored in it normal size and small sizes(32x32,96x96,110x140));

seeing the imgAttribute,sizeAttribute,cropeSize I really don’t understand how should I configure the behavior and how illustrated store these link and

what can I do when I want to display one the images

I also get an error saying Class ‘sjaakp\illustrated\Uploader’ not found in my view on the ligne where I put the widget, what is wrong ?


 <?= $form->field($model, 'lienphoto')->widget(Uploader::className(), [ 

                                   'stylefileOptions' => [

                                        'btnClass' => 'btn btn-success',

                                        'btnText' => 'Upload image']]) ?>

That is the line giving error;I didn’t forget to put use sjaakp\illustrated\Uploader;

and the class Uploader is there.

The problem was with the installation which I did manually because the composer prompting error and not installing; Details about error can be found on ; The error of composer was coming from the fact that I use YII that I implemented manually so I didn’t execute the command :composer global require “fxp/composer-asset-plugin:~1.0.3” but after executing this command I tried to reinstall the extension using composer and installation was successfull and the error was no longer there.