The module is expansion ElFinder Input. If you use a text field to add pictures displayed thumbs., (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist xtarantulz/yii2-input-img-preview "dev-master"
or add, (*4)
"xtarantulz/yii2-input-img-preview": "dev-master"
to the require section of your composer.json
file., (*5)
Usage
Once the extension is installed, simply use it in your code by :, (*6)
use mihaildev\elfinder\InputFile;
use mihaildev\elfinder\ElFinder;
use xtarantulz\preview\PreviewAsset;
PreviewAsset::register($this);
echo $form->field($model, 'images')->widget(InputFile::className(), [
'language' => 'ru',
'controller' => 'elfinder', // вставляем название контроллера, по умолчанию равен elfinder
'filter' => 'image', // фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#wiki-onlyMimes
'template' => '
{input}{button}
',
'options' => ['class' => 'form-control img'],
'buttonOptions' => ['class' => 'btn btn-success'],
'multiple' => true // возможность выбора нескольких файлов
]);
Screenshot
, (*7)