@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | public function getImagePath() |
| 87 | 87 | { |
| 88 | 88 | if ($this->imagePath === null) { |
| 89 | - $this->imagePath = '/images/' . strtolower((new \ReflectionClass($this->owner))->getShortName()); |
|
| 89 | + $this->imagePath = '/images/'.strtolower((new \ReflectionClass($this->owner))->getShortName()); |
|
| 90 | 90 | } |
| 91 | 91 | return $this->imagePath; |
| 92 | 92 | } |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | public function getImageAbsolutePath() |
| 109 | 109 | { |
| 110 | 110 | if ($this->_imageAbsolutePath === null) { |
| 111 | - $this->_imageAbsolutePath = Yii::getAlias('@webroot') . |
|
| 112 | - '/' . (defined('IS_BACKEND') ? '../' : '') . |
|
| 111 | + $this->_imageAbsolutePath = Yii::getAlias('@webroot'). |
|
| 112 | + '/'.(defined('IS_BACKEND') ? '../' : ''). |
|
| 113 | 113 | ltrim($this->getImagePath(), '/'); |
| 114 | 114 | if (!file_exists($this->_imageAbsolutePath)) { |
| 115 | 115 | yii\helpers\FileHelper::createDirectory($this->_imageAbsolutePath); |
@@ -145,8 +145,7 @@ discard block |
||
| 145 | 145 | public function getImageUrl() |
| 146 | 146 | { |
| 147 | 147 | return !$this->hasImage() ? |
| 148 | - $this->getImageDefaultUrl() : |
|
| 149 | - $this->_imageUrl($this->owner->getAttribute($this->imageAttribute)); |
|
| 148 | + $this->getImageDefaultUrl() : $this->_imageUrl($this->owner->getAttribute($this->imageAttribute)); |
|
| 150 | 149 | } |
| 151 | 150 | |
| 152 | 151 | /** |
@@ -155,7 +154,7 @@ discard block |
||
| 155 | 154 | */ |
| 156 | 155 | public function getImageFile() |
| 157 | 156 | { |
| 158 | - return $this->getImageAbsolutePath() . '/' . $this->owner->getAttribute($this->imageAttribute); |
|
| 157 | + return $this->getImageAbsolutePath().'/'.$this->owner->getAttribute($this->imageAttribute); |
|
| 159 | 158 | } |
| 160 | 159 | |
| 161 | 160 | /** |
@@ -188,10 +187,10 @@ discard block |
||
| 188 | 187 | if (!file_exists($sourceFile)) { |
| 189 | 188 | return false; |
| 190 | 189 | } |
| 191 | - $imageName = $this->imageAttribute . '_' . |
|
| 192 | - md5(implode('-', (array)$this->owner->getPrimaryKey()) . microtime(true) . rand()) . |
|
| 193 | - '.' . pathinfo($fileName)['extension']; |
|
| 194 | - $destinationFile = $this->getImageAbsolutePath() . '/' . $imageName; |
|
| 190 | + $imageName = $this->imageAttribute.'_'. |
|
| 191 | + md5(implode('-', (array) $this->owner->getPrimaryKey()).microtime(true).rand()). |
|
| 192 | + '.'.pathinfo($fileName)['extension']; |
|
| 193 | + $destinationFile = $this->getImageAbsolutePath().'/'.$imageName; |
|
| 195 | 194 | if (!copy($sourceFile, $destinationFile)) { |
| 196 | 195 | return false; |
| 197 | 196 | } |
@@ -241,7 +240,7 @@ discard block |
||
| 241 | 240 | */ |
| 242 | 241 | protected function _imageUrl($imageFileName) |
| 243 | 242 | { |
| 244 | - return $this->getImagePath() . '/' . $imageFileName; |
|
| 243 | + return $this->getImagePath().'/'.$imageFileName; |
|
| 245 | 244 | } |
| 246 | 245 | |
| 247 | 246 | } |