andrewdanilov/yii2-input-images
Composer 安装命令:
composer require andrewdanilov/yii2-input-images
包简介
Input images widget
README 文档
README
Widget building form fields for uploading single or multiple images. It extends and requires extension MihailDev/yii2-elfinder
Installation
The preferred way to install this extension is through composer.
Either run
composer require andrewdanilov/yii2-input-images "~1.0.0"
or add
"andrewdanilov/yii2-input-images": "~1.0.0"
to the require section of your composer.json file.
Usage
For use without a file manager
In your config/main.php add:
return [ // ... 'controllerMap' => [ 'uploader' => [ 'class' => 'andrewdanilov\InputImages\UploadController', 'path' => '@frontend/web/upload/post/images', // writable path to upload images to, default is '@webroot/upload/images' 'baseUrl' => '/upload/post/images', // base url to uploaded images, default is '/upload/images' ], ], ];
Then in view just add a widget call:
<?php use andrewdanilov\InputImages\InputImagesSimple; ?> <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'logo')->widget(InputImagesSimple::class) ?> <?php ActiveForm::end(); ?>
For use with the file manager
In your config/main.php add:
return [ // ... 'controllerMap' => [ 'elfinder' => [ 'class' => 'mihaildev\elfinder\Controller', 'access' => ['admin'], 'roots' => [ [ 'baseUrl' => '', 'basePath' => '@frontend/web', 'path' => 'upload/images', 'name' => 'Изображения', ], ], ], ], ];
And then add form in your view:
<?php use andrewdanilov\InputImages\InputImages; ?> <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'logo')->widget(InputImages::class) ?> <?php ActiveForm::end(); ?>
统计信息
- 总下载量: 220
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-16