Commit bace91ee420f120d6ce895e89540af15bdff00e4

Authored by Karnovsky A
1 parent 22827c55

-

backend/controllers/ArticlesController.php
... ... @@ -9,6 +9,8 @@ use yii\web\Controller;
9 9 use yii\web\NotFoundHttpException;
10 10 use yii\filters\VerbFilter;
11 11 use developeruz\db_rbac\behaviors\AccessBehavior;
  12 +use yii\web\UploadedFile;
  13 +
12 14 /**
13 15 * ArticlesController implements the CRUD actions for Articles model.
14 16 */
... ... @@ -77,7 +79,16 @@ class ArticlesController extends Controller
77 79 {
78 80 $model = new Articles();
79 81  
80   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
  82 + if ($model->load(Yii::$app->request->post())) {
  83 +
  84 + if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
  85 + $model->image = $image->name;
  86 + }
  87 +
  88 + if ($model->save() && $image) {
  89 + $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));
  90 + }
  91 +
81 92 return $this->redirect(['view', 'id' => $model->id]);
82 93 } else {
83 94 return $this->render('create', [
... ... @@ -96,7 +107,16 @@ class ArticlesController extends Controller
96 107 {
97 108 $model = $this->findModel($id);
98 109  
99   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
  110 + if ($model->load(Yii::$app->request->post())) {
  111 +
  112 + if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
  113 + $model->image = $image->name;
  114 + }
  115 +
  116 + if ($model->save() && $image) {
  117 + $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));
  118 + }
  119 +
100 120 return $this->redirect(['view', 'id' => $model->id]);
101 121 } else {
102 122 return $this->render('update', [
... ...
backend/controllers/BlogController.php
... ... @@ -79,10 +79,18 @@ class BlogController extends Controller
79 79 {
80 80 $model = new Blog();
81 81  
82   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
  82 + if ($model->load(Yii::$app->request->post())) {
83 83  
84 84 Fields::saveFieldData(Yii::$app->request->post('Fields'), $model->blog_id, Blog::className(), 'ru');
85 85  
  86 + if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
  87 + $model->cover = $image->name;
  88 + }
  89 +
  90 + if ($model->save() && $image) {
  91 + $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));
  92 + }
  93 +
86 94 return $this->redirect(['view', 'id' => $model->blog_id]);
87 95 } else {
88 96 return $this->render('create', [
... ... @@ -101,8 +109,18 @@ class BlogController extends Controller
101 109 {
102 110 $model = $this->findModel($id);
103 111  
104   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
  112 + if ($model->load(Yii::$app->request->post())) {
  113 +
105 114 Fields::saveFieldData(Yii::$app->request->post('Fields'), $model->blog_id, Blog::className(), 'ru');
  115 +
  116 + if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
  117 + $model->cover = $image->name;
  118 + }
  119 +
  120 + if ($model->save() && $image) {
  121 + $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name));
  122 + }
  123 +
106 124 return $this->redirect(['view', 'id' => $model->blog_id]);
107 125 } else {
108 126 return $this->render('update', [
... ...
backend/controllers/BrandController.php
... ... @@ -9,6 +9,8 @@ use yii\web\Controller;
9 9 use yii\web\NotFoundHttpException;
10 10 use yii\filters\VerbFilter;
11 11 use yii\filters\AccessControl;
  12 +use yii\web\UploadedFile;
  13 +
12 14 /**
13 15 * BrandController implements the CRUD actions for Brand model.
14 16 */
... ... @@ -78,8 +80,15 @@ class BrandController extends Controller
78 80 public function actionCreate()
79 81 {
80 82 $model = new Brand();
81   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
82   - exit;
  83 + if ($model->load(Yii::$app->request->post())) {
  84 + if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
  85 + $model->image = $image->name;
  86 + }
  87 +
  88 + if ($model->save() && $image) {
  89 + $image->saveAs(Yii::getAlias('@imagesDir/brands/' . $image->name));
  90 + }
  91 +
83 92 return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect(['view', 'id' => $model->brand_id]) : $this->redirect(array_merge(['create'], Yii::$app->request->queryParams));
84 93 } else {
85 94 return $this->render('create', [
... ... @@ -99,13 +108,15 @@ class BrandController extends Controller
99 108 $model = $this->findModel($id);
100 109  
101 110 if ($model->load(Yii::$app->request->post())) {
102   -// var_dump($_POST);
103   -// print "<hr>";
104   -// var_dump($_FILES);
105   -// exit;
106   - if ($model->save()) {
107   - return $this->redirect(['view', 'id' => $model->brand_id]);
  111 + if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
  112 + $model->image = $image->name;
  113 + }
  114 +
  115 + if ($model->save() && $image) {
  116 + $image->saveAs(Yii::getAlias('@imagesDir/brands/' . $image->name));
108 117 }
  118 +
  119 + return $this->redirect(['view', 'id' => $model->brand_id]);
109 120 } else {
110 121 return $this->render('update', [
111 122 'model' => $model,
... ...
backend/controllers/CategoryController.php
... ... @@ -11,6 +11,8 @@ use yii\web\Controller;
11 11 use yii\web\NotFoundHttpException;
12 12 use yii\filters\VerbFilter;
13 13 use yii\filters\AccessControl;
  14 +use yii\web\UploadedFile;
  15 +
14 16 /**
15 17 * CategoryController implements the CRUD actions for Category model.
16 18 */
... ... @@ -79,7 +81,15 @@ class CategoryController extends Controller
79 81 {
80 82 $model = new Category();
81 83  
82   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
  84 + if ($model->load(Yii::$app->request->post())) {
  85 + if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
  86 + $model->image = $image->name;
  87 + }
  88 +
  89 + if ($model->save() && $image) {
  90 + $image->saveAs(Yii::getAlias('@imagesDir/categories/' . $image->name));
  91 + }
  92 +
83 93 return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect(['view', 'id' => $model->category_id]) : $this->redirect(array_merge(['create'], Yii::$app->request->queryParams));
84 94 } else {
85 95 if (!empty(Yii::$app->request->queryParams['parent'])) {
... ... @@ -102,7 +112,15 @@ class CategoryController extends Controller
102 112 {
103 113 $model = $this->findModel($id);
104 114  
105   - if ($model->load(Yii::$app->request->post()) && $model->save()) {
  115 + if ($model->load(Yii::$app->request->post())) {
  116 + if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) {
  117 + $model->image = $image->name;
  118 + }
  119 +
  120 + if ($model->save() && $image) {
  121 + $image->saveAs(Yii::getAlias('@imagesDir/categories/' . $image->name));
  122 + }
  123 +
106 124 return $this->redirect(['view', 'id' => $model->category_id]);
107 125 } else {
108 126 return $this->render('update', [
... ...
backend/views/articles/_form.php
... ... @@ -13,7 +13,10 @@ use yii\jui\DatePicker;
13 13  
14 14 <div class="articles-form">
15 15  
16   - <?php $form = ActiveForm::begin(); ?>
  16 + <?php $form = ActiveForm::begin([
  17 + 'enableClientValidation' => false,
  18 + 'options' => ['enctype' => 'multipart/form-data']
  19 + ]); ?>
17 20  
18 21  
19 22 <?= $form->field($model, 'date')
... ... @@ -34,7 +37,21 @@ use yii\jui\DatePicker;
34 37 ]) ?>
35 38  
36 39  
37   - <?= $form->field($model, 'image')->textInput(['maxlength' => true]) ?>
  40 + <?= $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
  41 + 'language' => 'ru',
  42 + 'options' => [
  43 + 'accept' => 'image/*',
  44 + 'multiple' => false,
  45 + ],
  46 + 'pluginOptions' => [
  47 + 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
  48 + 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  49 + 'overwriteInitial' => true,
  50 + 'showRemove' => false,
  51 + 'showUpload' => false,
  52 + 'previewFileType' => 'image',
  53 + ],
  54 + ]); ?>
38 55  
39 56 <?= $form->field($model, 'translit')->textInput(['maxlength' => true]) ?>
40 57  
... ...
backend/views/blog/_form.php
... ... @@ -15,7 +15,10 @@ use common\components\Request;
15 15  
16 16 <div class="blog-form">
17 17  
18   - <?php $form = ActiveForm::begin(); ?>
  18 + <?php $form = ActiveForm::begin([
  19 + 'enableClientValidation' => false,
  20 + 'options' => ['enctype' => 'multipart/form-data']
  21 + ]); ?>
19 22  
20 23 <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
21 24  
... ... @@ -31,20 +34,21 @@ use common\components\Request;
31 34 )
32 35 ]) ?>
33 36  
34   - <?= ImageUploader::widget([
35   - 'model'=> $model,
36   - 'field'=>'cover',
37   - 'size' => [
38   - [
39   - 'width'=>340,
40   - 'height'=>260,
41   - ]
  37 + <?= $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
  38 + 'language' => 'ru',
  39 + 'options' => [
  40 + 'accept' => 'image/*',
  41 + 'multiple' => false,
42 42 ],
43   - 'multi'=>true,
44   - 'gallery' =>$model->cover,
45   - 'name' => 'Загрузить миниатюру статьи'
46   - ]);
47   - ?>
  43 + 'pluginOptions' => [
  44 + 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
  45 + 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  46 + 'overwriteInitial' => true,
  47 + 'showRemove' => false,
  48 + 'showUpload' => false,
  49 + 'previewFileType' => 'image',
  50 + ],
  51 + ]); ?>
48 52  
49 53 <?= FieldEditor::widget([
50 54 'template' => 'education',
... ...
backend/views/brand/_form.php
... ... @@ -19,7 +19,21 @@ use yii\widgets\ActiveForm;
19 19  
20 20 <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?>
21 21  
22   - <?= $form->field($model, 'image')->fileInput(['accept' => 'image/*']) ?>
  22 + <?= $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
  23 + 'language' => 'ru',
  24 + 'options' => [
  25 + 'accept' => 'image/*',
  26 + 'multiple' => false,
  27 + ],
  28 + 'pluginOptions' => [
  29 + 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
  30 + 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  31 + 'overwriteInitial' => true,
  32 + 'showRemove' => false,
  33 + 'showUpload' => false,
  34 + 'previewFileType' => 'image',
  35 + ],
  36 + ]); ?>
23 37  
24 38 <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
25 39  
... ...
backend/views/brand/view.php
... ... @@ -31,7 +31,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
31 31 'brand_id',
32 32 'brand_name_id',
33 33 'alias',
34   - 'image',
  34 + 'imageUrl:image',
35 35 'meta_title',
36 36 'meta_desc:ntext',
37 37 'meta_robots',
... ...
backend/views/category/_form.php
... ... @@ -12,7 +12,10 @@ use kartik\select2\Select2;
12 12  
13 13 <div class="category-form">
14 14  
15   - <?php $form = ActiveForm::begin(); ?>
  15 + <?php $form = ActiveForm::begin([
  16 + 'enableClientValidation' => false,
  17 + 'options' => ['enctype' => 'multipart/form-data']
  18 + ]); ?>
16 19  
17 20 <?= $form->field($model, 'name')->textInput() ?>
18 21  
... ... @@ -25,13 +28,6 @@ use kartik\select2\Select2;
25 28 ]
26 29 ])->label(Yii::t('product', 'Parent category')) ?>
27 30  
28   - <?php /*
29   - <?= $form->field($model, 'group_to_category')->dropDownList(
30   - \yii\helpers\ArrayHelper::map(\common\modules\rubrication\models\TaxGroup::find()->all(), 'tax_group_id', 'name'), [
31   - 'multiple' => true
32   - ])->label(Yii::t('product', 'Linked options')) ?>
33   - */?>
34   -
35 31 <?= $form->field($model, 'group_to_category')->widget(Select2::className(), [
36 32 'data' => \yii\helpers\ArrayHelper::map(\common\modules\rubrication\models\TaxGroup::find()->all(), 'tax_group_id', 'name'),
37 33 'language' => 'ru',
... ... @@ -45,20 +41,21 @@ use kartik\select2\Select2;
45 41 ]
46 42 ) ?>
47 43  
48   - <?= ImageUploader::widget([
49   - 'model'=> $model,
50   - 'field'=>'image',
51   - 'size' => [
52   - [
53   - 'width'=>340,
54   - 'height'=>260,
55   - ]
  44 + <?= $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
  45 + 'language' => 'ru',
  46 + 'options' => [
  47 + 'accept' => 'image/*',
  48 + 'multiple' => false,
  49 + ],
  50 + 'pluginOptions' => [
  51 + 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
  52 + 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  53 + 'overwriteInitial' => true,
  54 + 'showRemove' => false,
  55 + 'showUpload' => false,
  56 + 'previewFileType' => 'image',
56 57 ],
57   - 'multi'=>false,
58   - 'gallery' => $model->image,
59   - 'name' => 'Загрузить изображение'
60   - ]);
61   - ?>
  58 + ]); ?>
62 59  
63 60 <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
64 61  
... ...
backend/views/category/view.php
... ... @@ -36,7 +36,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
36 36 'parent_id',
37 37 'path',
38 38 'depth',
39   - 'image',
  39 + 'imageUrl:image',
40 40 'meta_title',
41 41 'meta_desc:ntext',
42 42 'meta_robots',
... ...
common/components/artboximage/ArtboxImageBehavior.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\components\artboximage;
  4 +
  5 +use Yii;
  6 +use yii\base\Behavior;
  7 +
  8 +class ArtboxImageBehavior extends Behavior {
  9 +
  10 +}
0 11 \ No newline at end of file
... ...
common/config/bootstrap.php
... ... @@ -4,3 +4,6 @@ Yii::setAlias(&#39;@frontend&#39;, dirname(dirname(__DIR__)) . &#39;/frontend&#39;);
4 4 Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
5 5 Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
6 6 Yii::setAlias('storage', dirname(dirname(__DIR__)) . '/storage');
  7 +
  8 +Yii::setAlias('@imagesDir', dirname(dirname(__DIR__)) . '/frontend/web/images');
  9 +Yii::setAlias('@imagesUrl', '/images');
... ...
common/models/Articles.php
... ... @@ -21,6 +21,8 @@ use Yii;
21 21 */
22 22 class Articles extends \yii\db\ActiveRecord
23 23 {
  24 + public $imageUpload;
  25 +
24 26 /**
25 27 * @inheritdoc
26 28 */
... ... @@ -39,6 +41,8 @@ class Articles extends \yii\db\ActiveRecord
39 41 [['title', 'body', 'image', 'translit'], 'required'],
40 42 [['body', 'seo_text'], 'string'],
41 43 [['title', 'image', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255],
  44 + [['imageUpload'], 'safe'],
  45 + [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
42 46 ];
43 47 }
44 48  
... ... @@ -53,6 +57,7 @@ class Articles extends \yii\db\ActiveRecord
53 57 'title' => 'Title',
54 58 'body' => 'Body',
55 59 'image' => 'Image',
  60 + 'imageUrl' => Yii::t('app', 'Image'),
56 61 'translit' => 'Translit',
57 62 'meta_title' => 'Meta Title',
58 63 'meta_keywords' => 'Meta Keywords',
... ... @@ -61,4 +66,13 @@ class Articles extends \yii\db\ActiveRecord
61 66 'h1' => 'H1',
62 67 ];
63 68 }
  69 +
  70 + public function getImageFile() {
  71 + return empty($this->image) ? null : Yii::getAlias('@imagesDir/articles/'. $this->image);
  72 + }
  73 +
  74 + public function getImageUrl()
  75 + {
  76 + return empty($this->image) ? null : Yii::getAlias('@imagesUrl/articles/' . $this->image);
  77 + }
64 78 }
... ...
common/models/Blog.php
... ... @@ -21,6 +21,7 @@
21 21 */
22 22 class Blog extends \yii\db\ActiveRecord
23 23 {
  24 + public $imageUpload;
24 25  
25 26 /**
26 27 * @inheritdoc
... ... @@ -80,6 +81,8 @@
80 81 'string',
81 82 'max' => 255,
82 83 ],
  84 + [['imageUpload'], 'safe'],
  85 + [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
83 86 ];
84 87 }
85 88  
... ... @@ -102,6 +105,17 @@
102 105 'view_count' => Yii::t('app', 'view_count'),
103 106 'description' => Yii::t('app', 'description'),
104 107 'cover' => Yii::t('app', 'cover'),
  108 + 'image' => Yii::t('app', 'cover'),
  109 + 'imageUrl' => Yii::t('app', 'cover'),
105 110 ];
106 111 }
  112 +
  113 + public function getImageFile() {
  114 + return empty($this->image) ? null : Yii::getAlias('@imagesDir/brands/'. $this->image);
  115 + }
  116 +
  117 + public function getImageUrl()
  118 + {
  119 + return empty($this->image) ? null : Yii::getAlias('@imagesUrl/brands/' . $this->image);
  120 + }
107 121 }
... ...
common/modules/product/models/Brand.php
... ... @@ -4,8 +4,7 @@ namespace common\modules\product\models;
4 4  
5 5 use common\behaviors\Slug;
6 6 use common\modules\rubrication\behaviors\ArtboxSynonymBehavior;
7   -use mongosoft\file\UploadBehavior;
8   -use mongosoft\file\UploadImageBehavior;
  7 +use yii\web\UploadedFile;
9 8 use Yii;
10 9  
11 10 /**
... ... @@ -27,6 +26,8 @@ use Yii;
27 26 */
28 27 class Brand extends \yii\db\ActiveRecord
29 28 {
  29 + public $imageUpload;
  30 +
30 31 public function behaviors()
31 32 {
32 33 return [
... ... @@ -43,18 +44,6 @@ class Brand extends \yii\db\ActiveRecord
43 44 'slugKeyName' => 'alias',
44 45 'translit' => true
45 46 ],
46   - 'uploader' => [
47   - 'class' => UploadBehavior::className(),
48   - 'attribute' => 'fileUpload',
49   - 'scenarios' => ['insert', 'update'],
50   -// 'placeholder' => '@app/modules/user/assets/images/userpic.jpg',
51   - 'path' => '@storage/brands/{alias}',
52   - 'url' => '/storage/brands/{alias}',
53   -// 'thumbs' => [
54   -// 'thumb' => ['width' => 400, 'quality' => 90],
55   -// 'preview' => ['width' => 200, 'height' => 200],
56   -// ],
57   - ],
58 47 ],
59 48 ];
60 49 }
... ... @@ -77,10 +66,10 @@ class Brand extends \yii\db\ActiveRecord
77 66 [['brand_name_id'], 'integer'],
78 67 [['meta_desc', 'seo_text'], 'string'],
79 68 [['alias', 'name'], 'string', 'max' => 250],
80   - [['meta_title'], 'string', 'max' => 255],
  69 + [['meta_title', 'image'], 'string', 'max' => 255],
81 70 [['meta_robots'], 'string', 'max' => 50],
82   - [['fileUpload'], 'file', 'extensions' => 'jpg, gif, png'],
83   -// [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']],
  71 + [['imageUpload'], 'safe'],
  72 + [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
84 73 ];
85 74 }
86 75  
... ... @@ -132,10 +121,11 @@ class Brand extends \yii\db\ActiveRecord
132 121 }
133 122  
134 123 public function getImageFile() {
135   - return empty($this->image) ? null : '/images/brand/'. $this->image;
  124 + return empty($this->image) ? null : Yii::getAlias('@imagesDir/brands/'. $this->image);
136 125 }
137 126  
138   - public function getImageUrl() {
139   - return empty($this->image) ? null : '/images/brand/'. $this->image;
  127 + public function getImageUrl()
  128 + {
  129 + return empty($this->image) ? null : Yii::getAlias('@imagesUrl/brands/' . $this->image);
140 130 }
141 131 }
... ...
common/modules/product/models/Category.php
... ... @@ -85,7 +85,7 @@ class Category extends \yii\db\ActiveRecord
85 85 [['name'], 'string'],
86 86 [['parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'],
87 87 [['path', 'meta_desc', 'seo_text'], 'string'],
88   - [['meta_title'], 'string', 'max' => 255],
  88 + [['meta_title', 'image'], 'string', 'max' => 255],
89 89 [['meta_robots'], 'string', 'max' => 50],
90 90 [['alias', 'name'], 'string', 'max' => 250],
91 91 [['populary'], 'boolean'],
... ... @@ -93,7 +93,6 @@ class Category extends \yii\db\ActiveRecord
93 93 [['category_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => CategoryName::className(), 'targetAttribute' => ['category_name_id' => 'category_name_id']],
94 94 [['imageUpload'], 'safe'],
95 95 [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
96   -// [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']],
97 96 ];
98 97 }
99 98  
... ... @@ -172,14 +171,17 @@ class Category extends \yii\db\ActiveRecord
172 171 return $this->hasOne(CategoryName::className(), ['category_name_id' => 'category_name_id']);
173 172 }
174 173  
175   - public function getName()
176   - {
  174 + public function getName() {
177 175 return empty($this->categoryName) ? null : $this->categoryName->value;
178 176 }
179 177  
  178 + public function getImageFile() {
  179 + return empty($this->image) ? null : Yii::getAlias('@imagesDir/categories/'. $this->image);
  180 + }
  181 +
180 182 public function getImageUrl()
181 183 {
182   - return empty($this->image) ? null : '/images/category/' . $this->image;
  184 + return empty($this->image) ? null : Yii::getAlias('@imagesUrl/categories/' . $this->image);
183 185 }
184 186  
185 187 public function beforeSave($insert)
... ...
frontend/views/articles/index.php
... ... @@ -27,7 +27,9 @@ $this-&gt;registerMetaTag([&#39;name&#39; =&gt; &#39;keywords&#39;, &#39;content&#39; =&gt; &#39;Блог&#39;]);
27 27  
28 28 <?php foreach($news as $item):?>
29 29 <div class="news_item">
30   - <a href="<?=Url::to(['articles/show','translit'=>$item->translit,'id'=>$item->id])?>"><img src="<?=Yii::$app->request->baseUrl.'/storage/articles/ico/'.$item->image?>" width="180" height="125" border="0" align="left" /></a>
  30 + <a href="<?=Url::to(['articles/show','translit'=>$item->translit,'id'=>$item->id])?>">
  31 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($item->imageUrl, 'list')?>
  32 + </a>
31 33 <a href="<?=Url::to(['articles/show','translit'=>$item->translit,'id'=>$item->id])?>" class="name"><?=$item->title?></a><br />
32 34 <?=Text::getShort($item->body,600);?><div class="both"></div>
33 35 </div>
... ...
frontend/views/articles/show.php
... ... @@ -22,8 +22,7 @@ $this-&gt;registerMetaTag([&#39;name&#39; =&gt; &#39;keywords&#39;, &#39;content&#39; =&gt; $news-&gt;meta_keywords]
22 22  
23 23 <div class="content">
24 24 <h1><?=$news->title?></h1>
25   -
26   - <img src="<?=Yii::$app->request->baseUrl.'/storage/articles/big/'.$news->image?>" width="400" height="400" border="0" align="left" class='pic' />
  25 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($news->imageUrl, 'product')?>
27 26 <?=$news->body?>
28 27 <p class='date'><?=$news->date?></p>
29 28 </div>
... ...
frontend/views/catalog/product_item.php
... ... @@ -9,11 +9,7 @@ use yii\helpers\Url;
9 9 'catalog/product',
10 10 'product' => $product])
11 11 ?>">
12   - <?php if (empty($product->image)) :?>
13   - <img src="/img/no_photo.png">
14   - <?php else :?>
15   - <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->image->imageUrl, 'list')?>
16   - <?php endif?>
  12 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->imageUrl, 'list')?>
17 13 </a>
18 14 </div>
19 15 <a href="<?= Url::to([
... ...