@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function getImagePath() |
107 | 107 | { |
108 | 108 | if ($this->imagePath === null) { |
109 | - $this->imagePath = '/images/' . strtolower((new \ReflectionClass($this->owner))->getShortName()); |
|
109 | + $this->imagePath = '/images/'.strtolower((new \ReflectionClass($this->owner))->getShortName()); |
|
110 | 110 | } |
111 | 111 | return $this->imagePath; |
112 | 112 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | public function getImageAbsolutePath() |
129 | 129 | { |
130 | 130 | if ($this->_imageAbsolutePath === null) { |
131 | - $this->_imageAbsolutePath = Yii::getAlias('@webroot') . |
|
132 | - '/' . (defined('IS_BACKEND') ? '../' : '') . |
|
131 | + $this->_imageAbsolutePath = Yii::getAlias('@webroot'). |
|
132 | + '/'.(defined('IS_BACKEND') ? '../' : ''). |
|
133 | 133 | ltrim($this->getImagePath(), '/'); |
134 | 134 | if (!file_exists($this->_imageAbsolutePath)) { |
135 | 135 | yii\helpers\FileHelper::createDirectory($this->_imageAbsolutePath); |
@@ -165,8 +165,7 @@ discard block |
||
165 | 165 | public function getImageUrl() |
166 | 166 | { |
167 | 167 | return !$this->hasImage() ? |
168 | - $this->getImageDefaultUrl() : |
|
169 | - $this->_imageUrl($this->owner->getAttribute($this->imageAttribute)); |
|
168 | + $this->getImageDefaultUrl() : $this->_imageUrl($this->owner->getAttribute($this->imageAttribute)); |
|
170 | 169 | } |
171 | 170 | |
172 | 171 | /** |
@@ -175,7 +174,7 @@ discard block |
||
175 | 174 | */ |
176 | 175 | public function getImageFile() |
177 | 176 | { |
178 | - return $this->getImageAbsolutePath() . '/' . $this->owner->getAttribute($this->imageAttribute); |
|
177 | + return $this->getImageAbsolutePath().'/'.$this->owner->getAttribute($this->imageAttribute); |
|
179 | 178 | } |
180 | 179 | |
181 | 180 | /** |
@@ -208,10 +207,10 @@ discard block |
||
208 | 207 | if (!file_exists($sourceFile)) { |
209 | 208 | return false; |
210 | 209 | } |
211 | - $imageName = $this->imageAttribute . '_' . |
|
212 | - md5(implode('-', (array)$this->owner->getPrimaryKey()) . microtime(true) . rand()) . |
|
213 | - '.' . pathinfo($fileName)['extension']; |
|
214 | - $destinationFile = $this->getImageAbsolutePath() . '/' . $imageName; |
|
210 | + $imageName = $this->imageAttribute.'_'. |
|
211 | + md5(implode('-', (array) $this->owner->getPrimaryKey()).microtime(true).rand()). |
|
212 | + '.'.pathinfo($fileName)['extension']; |
|
213 | + $destinationFile = $this->getImageAbsolutePath().'/'.$imageName; |
|
215 | 214 | if (!copy($sourceFile, $destinationFile)) { |
216 | 215 | return false; |
217 | 216 | } |
@@ -234,8 +233,7 @@ discard block |
||
234 | 233 | yii\imagine\Image::getImagine(), |
235 | 234 | $newBox, |
236 | 235 | $size[0] == $currentBox->getWidth() ? |
237 | - new Point(0, ($size[1] - $currentBox->getHeight()) / 2) : |
|
238 | - new Point(($size[0] - $currentBox->getWidth()) / 2, 0), |
|
236 | + new Point(0, ($size[1] - $currentBox->getHeight()) / 2) : new Point(($size[0] - $currentBox->getWidth()) / 2, 0), |
|
239 | 237 | new Color($this->imageFrameColor) |
240 | 238 | ) |
241 | 239 | )->apply($image); |
@@ -277,7 +275,7 @@ discard block |
||
277 | 275 | */ |
278 | 276 | protected function _imageUrl($imageFileName) |
279 | 277 | { |
280 | - return $this->getImagePath() . '/' . $imageFileName; |
|
278 | + return $this->getImagePath().'/'.$imageFileName; |
|
281 | 279 | } |
282 | 280 | |
283 | 281 | } |