Renders a Dropzone Input widget.
The preferred way to install this extension is through composer.
Either run
$ composer require singularity/yii2-dropzoneinput:~1.0
or add
"singularity/yii2-dropzoneinput": "~1.0"
to the require
section of your composer.json
file.
Using with ActiveForm
use singularity\dropzoneinput\DropzoneInput;
...
<?= $form->field($model, 'imageIds'])->widget(DropzoneInput::class, [
'files' => $data
]); ?>
Using without ActiveForm
use singularity\dropzoneinput\DropzoneInput;
...
<?= DropzoneInput::widget([
'model' => $model,
'attribute' => 'imageIds',
'files' => $data
]) ?>
Example:
[
'files' => $files // default empty
]
Expected file format:
$file = [
'id' => 100,
'name' => 'My image',
'size' => 5,
'status' => 'success',
'url' => Url::to(['/image/view', 'id' => 100, 'spec' => 'w120']), // dropzone thumbnail image url
'src' => Url::to(['/image/view', 'id' => 100, 'spec' => 'w1200']) // full preview image url
];
Example:
[
'highlightFirst' => true // default false
]
Example:
[
'enableRotate' => true // default false
'clientOptions' => [
'rotateUrl' => Url::to(['/image/rotate'])
]
]
Example:
[
'enablePreview' => true // default false
]
Example:
[
'enableSort' => true // default true
]
Example:
[
'enableCrop' => true // default false,
'cropperOptions' => [
'aspectRatio' => 1.4
],
'clientOptions' => [
'parallelUploads' => 1 // default 2 (it is recommended to set this to 1 when using crop)
],
'beforeCrop' => new JsExpression("function() {
console.log('Just before image is cropped!');
}"),
]
Example:
[
'removeMessage' => 'Are you sure you want to delete image?' //this is the default
]
see Cropper.JS for full documentation
Please see CONTRIBUTING for details.
The BSD License (BSD). Please see License File for more information.
#InventTomorrow
www.singularity.is