Commit a123b4b44c6e3bd1e18b6ac57f3ea10102d233da
1 parent
98e8e9e5
ArtboxImage uploader
Showing
3 changed files
with
27 additions
and
2 deletions
Show diff stats
backend/views/brand/_form.php
@@ -18,7 +18,7 @@ use yii\widgets\ActiveForm; | @@ -18,7 +18,7 @@ use yii\widgets\ActiveForm; | ||
18 | 18 | ||
19 | <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> | 19 | <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> |
20 | 20 | ||
21 | - <?= \common\components\artboximage\ArtboxImageHelper::fileinputWidget($model, 'image');?> | 21 | + <?= \common\components\artboximage\ArtboxImageHelper::fileinputWidget($model, 'imageUrl');?> |
22 | 22 | ||
23 | <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?> | 23 | <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?> |
24 | 24 |
common/components/artboximage/ArtboxImage.php
@@ -6,6 +6,7 @@ use kartik\file\FileInput; | @@ -6,6 +6,7 @@ use kartik\file\FileInput; | ||
6 | use Yii; | 6 | use Yii; |
7 | use yii\base\Component; | 7 | use yii\base\Component; |
8 | use yii\base\ErrorException; | 8 | use yii\base\ErrorException; |
9 | +use yii\helpers\Html; | ||
9 | use yii\image\drivers\Image; | 10 | use yii\image\drivers\Image; |
10 | 11 | ||
11 | //use common\components\artboximage\drivers\Image; | 12 | //use common\components\artboximage\drivers\Image; |
@@ -49,7 +50,7 @@ class ArtboxImage extends Component { | @@ -49,7 +50,7 @@ class ArtboxImage extends Component { | ||
49 | 'pluginOptions' => [ | 50 | 'pluginOptions' => [ |
50 | 'allowedFileExtensions' => array_keys($this->extensions), | 51 | 'allowedFileExtensions' => array_keys($this->extensions), |
51 | // @todo set for multiple | 52 | // @todo set for multiple |
52 | - 'initialPreview' => $model->{$modelField} ? Html::img($modelField) : '', | 53 | + 'initialPreview' => $model->{$modelField} ? Html::img($model->{$modelField}) : '', |
53 | 'overwriteInitial' => !$multiple, | 54 | 'overwriteInitial' => !$multiple, |
54 | 'showRemove' => true, | 55 | 'showRemove' => true, |
55 | 'showUpload' => false, | 56 | 'showUpload' => false, |
@@ -59,6 +60,22 @@ class ArtboxImage extends Component { | @@ -59,6 +60,22 @@ class ArtboxImage extends Component { | ||
59 | 'multiple' => intval($multiple), | 60 | 'multiple' => intval($multiple), |
60 | ], | 61 | ], |
61 | ], | 62 | ], |
63 | + 'pluginEvents' => [ | ||
64 | + "change" => "function() { console.log('change'); }", | ||
65 | + "open" => "function() { console.log('open'); }", | ||
66 | + "save" => "function() { console.log('save'); }", | ||
67 | + "upload" => "function() { console.log('upload'); }", | ||
68 | + "uploaded" => "function() { console.log('uploaded'); }", | ||
69 | + "filepreupload" => "function() { console.log('filepreupload'); }", | ||
70 | + "fileuploaded" => "function(event, files, extra) { console.log(event, files, extra); }", | ||
71 | + "fileuploaderror" => "function() { console.log('fileuploaderror'); }", | ||
72 | + "filebatchuploaderror" => "function() { console.log('filebatchuploaderror'); }", | ||
73 | + "filebatchuploadsuccess" => "function() { console.log('filebatchuploadsuccess'); }", | ||
74 | + "filebatchuploadcomplete" => "function() { console.log('filebatchuploadcomplete'); }", | ||
75 | + 'filebatchuploadsuccess' => "function(event, files, extra) { | ||
76 | + console.log(event, files, extra); | ||
77 | + }", | ||
78 | + ], | ||
62 | ]); | 79 | ]); |
63 | } | 80 | } |
64 | } | 81 | } |
65 | \ No newline at end of file | 82 | \ No newline at end of file |
common/modules/artboxfile/controllers/ActionController.php
@@ -4,6 +4,7 @@ namespace common\modules\artboxfile\controllers; | @@ -4,6 +4,7 @@ namespace common\modules\artboxfile\controllers; | ||
4 | 4 | ||
5 | use common\modules\artboxfile\models\File; | 5 | use common\modules\artboxfile\models\File; |
6 | use Yii; | 6 | use Yii; |
7 | +use yii\helpers\Html; | ||
7 | use yii\web\Controller; | 8 | use yii\web\Controller; |
8 | use yii\web\UploadedFile; | 9 | use yii\web\UploadedFile; |
9 | 10 | ||
@@ -58,6 +59,13 @@ class ActionController extends Controller { | @@ -58,6 +59,13 @@ class ActionController extends Controller { | ||
58 | if (!empty($error)) { | 59 | if (!empty($error)) { |
59 | print json_encode(['error' => $error]); | 60 | print json_encode(['error' => $error]); |
60 | } else { | 61 | } else { |
62 | + $sendingData = [ | ||
63 | + 'append' => $multiple, | ||
64 | +// 'initialPreview' => Html::img() | ||
65 | +// 'initialPreviewConfig' => , | ||
66 | +// 'initialPreviewThumbTags' => , | ||
67 | + | ||
68 | + ]; | ||
61 | print json_encode(['message' => $message, 'tmpfile' => $full_path, 'filename' => $name]); | 69 | print json_encode(['message' => $message, 'tmpfile' => $full_path, 'filename' => $name]); |
62 | } | 70 | } |
63 | exit; | 71 | exit; |