Commit 159f29c24ef7d6ec0618bc1dbdd7777a5285d663
1 parent
04b510ec
Importers CRUD
Showing
3 changed files
with
11 additions
and
7 deletions
Show diff stats
backend/components/base/BaseController.php
| ... | ... | @@ -45,11 +45,9 @@ class BaseController extends Controller { |
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | } |
| 48 | - | |
| 48 | +// | |
| 49 | 49 | // private function resizeImg($w, $h, $filepath,$newfilepath){ |
| 50 | -// list($orig_width, $orig_height) = getimagesize($filepath); | |
| 51 | -// $width = $orig_width; | |
| 52 | -// $height = $orig_height; | |
| 50 | +// list($width, $height) = getimagesize($filepath); | |
| 53 | 51 | // if($width > $height) { |
| 54 | 52 | // $y = 0; |
| 55 | 53 | // $x = ($width - $height) / 2; |
| ... | ... | @@ -76,7 +74,7 @@ class BaseController extends Controller { |
| 76 | 74 | { |
| 77 | 75 | |
| 78 | 76 | $model = new ImageSizerForm(); |
| 79 | - //die(print_r(Yii::$app->request->post())); | |
| 77 | + | |
| 80 | 78 | if ($model->load(Yii::$app->request->post())) { |
| 81 | 79 | |
| 82 | 80 | $model->file = UploadedFile::getInstance($model, 'file'); |
| ... | ... | @@ -85,6 +83,7 @@ class BaseController extends Controller { |
| 85 | 83 | $imgDir = Yii::getAlias('@storage/'.$md5_file.'/'); |
| 86 | 84 | $imageAlias = Yii::getAlias($imgDir.$model->width.'x'.$model->height.'.'.$model->file->extension); |
| 87 | 85 | $imageLink = '/storage/'.$md5_file.$model->width.'x'.$model->height.'.'.$model->file->extension; |
| 86 | + | |
| 88 | 87 | if(!is_dir($imgDir)) { |
| 89 | 88 | mkdir($imgDir, 0755, true); |
| 90 | 89 | } | ... | ... |
backend/components/views/image_sizer.php
| ... | ... | @@ -12,7 +12,7 @@ $this->registerJsFile('@web/js/vendor/bower/jquery-file-upload/js/jquery.fileupl |
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | -<?= $form->field($model, 'file')->fileInput(['id'=>$field, 'data-url'=>"/admin/site/download-photo"]); ?> | |
| 15 | +<?= $form->field( new \backend\models\ImageSizerForm(), 'file')->fileInput(['id'=>$field, 'data-url'=>"/admin/site/download-photo"]); ?> | |
| 16 | 16 | |
| 17 | 17 | <?= $form->field($model,$field)->hiddenInput(['id' => "{$field}_picture_link"]) ?> |
| 18 | 18 | |
| ... | ... | @@ -25,7 +25,7 @@ $this->registerJsFile('@web/js/vendor/bower/jquery-file-upload/js/jquery.fileupl |
| 25 | 25 | |
| 26 | 26 | $("#<?= $field?>").fileupload({ |
| 27 | 27 | dataType: 'json', |
| 28 | - formData: { | |
| 28 | + ImageSizerForm: { | |
| 29 | 29 | height: <?=$height?>, |
| 30 | 30 | width: <?= $width?> |
| 31 | 31 | }, | ... | ... |
backend/models/ImageSizerForm.php