oxy-coach / yii2-images-upload-widget
Images upload widget working with yii2 image behavior
v1.0.1
2018-08-21 08:59 UTC
Requires
- php: >=7.0
- oxy-coach/yii2-image-behavior: >= 1.2.0
- yiisoft/yii2-jui: *
This package is not auto-updated.
Last update: 2025-03-30 08:17:37 UTC
README
Images upload widget working with ImageBehavior with sorting and deleting images via ajax.
Installation via Composer
Run the following command
$ composer require oxy-coach/yii2-images-upload-widget "*"
or add
$ "oxy-coach/yii2-images-upload-widget": "*"
to the require section of your composer.json
file.
Configuring
Add action in the controller, for example:
use oxycoach\imageswidget\SortImagesAction; use oxycoach\imageswidget\DeleteImagesAction; \\ ... public function actions() { return [ 'sort-images' => [ 'class' => SortImagesAction::class, 'modelName' => MyModel::class, ], 'delete-image' => [ 'class' => DeleteImagesAction::class, 'modelName' => MyModel::class, ], ]; }
Usage
use oxycoach\imageswidget\ImagesUploadWidget; <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> \\ ... <?= ImagesUploadWidget::widget([ 'form' => $form, 'model' => $model, 'name' => 'files', 'multiple' => true, 'size' => 'preview', 'sortAction' => ['sort-images'], 'deleteAction' => ['delete-image'], ]) ?>
Properties
Property | Type | Default | Description |
---|---|---|---|
name | string | model images property name | |
sortAction | array | ['sort-images'] |
route for image sorting url |
deleteAction | array | ['delete-image'] |
route for delete image url |
multiple | boolean | false |
flag for multiple images field |
size | string | 'preview' |
displaying images size - for more information checkout ImageBehavior |