PHP code example of artursharipov / img

1. Go to this page and download the library: Download artursharipov/img 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/ */

    

artursharipov / img example snippets



public function behaviors()
{
    return [
        'img' => [
            'class' => \artursharipov\img\behaviors\ImgBehavior::className(),
            'hashClass' => "Klass",
            'folder_image' => 'files/',
        ],
    ];
}


Yii::setAlias('@www', dirname(dirname(dirname(__DIR__))) . '/public_html');



$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);

    echo \artursharipov\img\widgets\sortable\Sortable::widget(['items'=>$model->imgGallery]);

    echo $form->field($model, 'new_imgs[]')->fileInput(['accept' => 'image/*', 'multiple'=>true]);

ActiveForm::end();



$form = ActiveForm::begin();

    echo \artursharipov\img\widgets\sortable\Sortable::widget(['items'=>$model->imgMain]);

    echo $form->field($model, 'new_img')->fileInput(['accept' => 'image/*']);

ActiveForm::end();



//get all images for model
$model->imgGallery;

//get one images for model
$model->imgMain;