@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function getImagePath() |
120 | 120 | { |
121 | 121 | if ($this->imagePath === null) { |
122 | - $this->imagePath = '/images/' . strtolower((new \ReflectionClass($this->owner))->getShortName()); |
|
122 | + $this->imagePath = '/images/'.strtolower((new \ReflectionClass($this->owner))->getShortName()); |
|
123 | 123 | } |
124 | 124 | return $this->imagePath; |
125 | 125 | } |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | public function getImageAbsolutePath() |
142 | 142 | { |
143 | 143 | if ($this->_imageAbsolutePath === null) { |
144 | - $this->_imageAbsolutePath = Yii::getAlias('@webroot') . |
|
145 | - '/' . (defined('IS_BACKEND') ? '../' : '') . |
|
144 | + $this->_imageAbsolutePath = Yii::getAlias('@webroot'). |
|
145 | + '/'.(defined('IS_BACKEND') ? '../' : ''). |
|
146 | 146 | ltrim($this->getImagePath(), '/'); |
147 | 147 | if (!file_exists($this->_imageAbsolutePath)) { |
148 | 148 | yii\helpers\FileHelper::createDirectory($this->_imageAbsolutePath); |
@@ -178,8 +178,7 @@ discard block |
||
178 | 178 | public function getImageUrl() |
179 | 179 | { |
180 | 180 | return !$this->hasImage() ? |
181 | - $this->getImageDefaultUrl() : |
|
182 | - $this->_imageUrl($this->owner->getAttribute($this->imageAttribute)); |
|
181 | + $this->getImageDefaultUrl() : $this->_imageUrl($this->owner->getAttribute($this->imageAttribute)); |
|
183 | 182 | } |
184 | 183 | |
185 | 184 | /** |
@@ -188,7 +187,7 @@ discard block |
||
188 | 187 | */ |
189 | 188 | public function getImageFile() |
190 | 189 | { |
191 | - return $this->getImageAbsolutePath() . '/' . $this->owner->getAttribute($this->imageAttribute); |
|
190 | + return $this->getImageAbsolutePath().'/'.$this->owner->getAttribute($this->imageAttribute); |
|
192 | 191 | } |
193 | 192 | |
194 | 193 | /** |
@@ -221,10 +220,10 @@ discard block |
||
221 | 220 | if (!file_exists($sourceFile)) { |
222 | 221 | return false; |
223 | 222 | } |
224 | - $imageName = $this->imageAttribute . '_' . |
|
225 | - md5(implode('-', (array)$this->owner->getPrimaryKey()) . microtime(true) . rand()) . |
|
226 | - '.' . pathinfo($fileName)['extension']; |
|
227 | - $destinationFile = $this->getImageAbsolutePath() . '/' . $imageName; |
|
223 | + $imageName = $this->imageAttribute.'_'. |
|
224 | + md5(implode('-', (array) $this->owner->getPrimaryKey()).microtime(true).rand()). |
|
225 | + '.'.pathinfo($fileName)['extension']; |
|
226 | + $destinationFile = $this->getImageAbsolutePath().'/'.$imageName; |
|
228 | 227 | if (!copy($sourceFile, $destinationFile)) { |
229 | 228 | return false; |
230 | 229 | } |
@@ -254,8 +253,7 @@ discard block |
||
254 | 253 | yii\imagine\Image::getImagine(), |
255 | 254 | $newBox, |
256 | 255 | $size[0] == $currentBox->getWidth() ? |
257 | - new Point(0, ($size[1] - $currentBox->getHeight()) / 2) : |
|
258 | - new Point(($size[0] - $currentBox->getWidth()) / 2, 0), |
|
256 | + new Point(0, ($size[1] - $currentBox->getHeight()) / 2) : new Point(($size[0] - $currentBox->getWidth()) / 2, 0), |
|
259 | 257 | new Color($frameColor, $alpha) |
260 | 258 | ) |
261 | 259 | )->apply($image); |
@@ -297,7 +295,7 @@ discard block |
||
297 | 295 | */ |
298 | 296 | protected function _imageUrl($imageFileName) |
299 | 297 | { |
300 | - return $this->getImagePath() . '/' . $imageFileName; |
|
298 | + return $this->getImagePath().'/'.$imageFileName; |
|
301 | 299 | } |
302 | 300 | |
303 | 301 | } |