consynki / yii2-image-input
A Yii2input widget to allow a better drag drop image upload
Installs: 2 774
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Language:JavaScript
Type:yii2-extension
Requires
- php: >=5.4.0
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-11-01 10:31:01 UTC
README
This extension provides a drag drop image field to inclusion within a standard Yii2 form. This extension dosn't provide any functionality for uploading the images, that can be done via the standard Yii form processing.
Installation
The preferred way to install this extension is through composer.
To install, either run
$ composer require consynki/yii2-image-input "*"
or add
"consynki/yii2-image-input": "*"
to the
require
section of your composer.json
file.
Usage
Alert
You can use the image input in a standard Yii form.
<?php use consynki\yii\input\ImageInput; use yii\helpers\Html; use yii\widgets\ActiveForm; ?> <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'image')->widget(ImageInput::className(), [ 'value' => '/img/current-image.png' //Optional current value ]); ?> <?= Html::submitButton('Save', []) ?> <?php ActiveForm::end(); ?>
You can pass in the optional value
to display a default image as the current value of the field.