@@ -22,14 +22,14 @@ |
||
22 | 22 | * @return string completed img tag. |
23 | 23 | * @see https://book.cakephp.org/3.0/en/views/helpers/html.html#linking-to-images |
24 | 24 | */ |
25 | - public function thumb($path, array $options = [], string $thumb = 'default'): string |
|
25 | + public function thumb($path, array $options = [ ], string $thumb = 'default'): string |
|
26 | 26 | { |
27 | 27 | if ($thumb !== 'default') { |
28 | 28 | $path = preg_replace('/default/', $thumb, $path); |
29 | 29 | } |
30 | 30 | |
31 | 31 | if (!is_array($options)) { |
32 | - $options = []; |
|
32 | + $options = [ ]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $this->Html->image($path, $options); |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | 'webp', |
45 | 45 | ], |
46 | 46 | 'path' => 'files', |
47 | - 'background' => [255, 255, 255, 127], |
|
47 | + 'background' => [ 255, 255, 255, 127 ], |
|
48 | 48 | 'watermark' => '', |
49 | - 'thumbs' => [], |
|
49 | + 'thumbs' => [ ], |
|
50 | 50 | ]; |
51 | 51 | |
52 | 52 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @var array |
56 | 56 | */ |
57 | - protected $files = []; |
|
57 | + protected $files = [ ]; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * {@inheritdoc} |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $this->setConfig($file, $this->defaultConfig); |
73 | 73 | } else { |
74 | - $this->setConfig($file, $config[$file] += $this->defaultConfig); |
|
74 | + $this->setConfig($file, $config[ $file ] += $this->defaultConfig); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | |
86 | 86 | if (!empty($config)) { |
87 | 87 | foreach (array_keys($config) as $file) { |
88 | - $this->setFile($file, $data[$file]); |
|
88 | + $this->setFile($file, $data[ $file ]); |
|
89 | 89 | |
90 | - $data[$file] = $this->createName($data[$file]->getClientFilename()); |
|
90 | + $data[ $file ] = $this->createName($data[ $file ]->getClientFilename()); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | $fileConfig = $this->getConfig($file); |
106 | 106 | |
107 | 107 | // Move original file |
108 | - $fileObject->moveTo($this->getPath($fileConfig['path']) . DS . $entity->{$file}); |
|
108 | + $fileObject->moveTo($this->getPath($fileConfig[ 'path' ]).DS.$entity->{$file}); |
|
109 | 109 | |
110 | 110 | // Prepare thumb files |
111 | - if (!empty($fileConfig['thumbs'])) { |
|
111 | + if (!empty($fileConfig[ 'thumbs' ])) { |
|
112 | 112 | $this->createThumbs($entity->{$file}, $fileConfig); |
113 | 113 | } |
114 | 114 | } |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | { |
124 | 124 | $entity = $this->getTable()->find()->select( |
125 | 125 | array_merge( |
126 | - [$this->getTable()->getPrimaryKey()], |
|
126 | + [ $this->getTable()->getPrimaryKey() ], |
|
127 | 127 | array_keys($this->getConfig()) |
128 | 128 | ) |
129 | 129 | )->where([ |
130 | - $this->getTable()->getAlias() . '.' . $this->getTable()->getPrimaryKey() => $entity->{$this->getTable()->getPrimaryKey()}, |
|
130 | + $this->getTable()->getAlias().'.'.$this->getTable()->getPrimaryKey() => $entity->{$this->getTable()->getPrimaryKey()}, |
|
131 | 131 | ])->first(); |
132 | 132 | |
133 | 133 | return $this->deleteFiles($entity); |
@@ -143,20 +143,20 @@ discard block |
||
143 | 143 | |
144 | 144 | protected function createThumbs(string $file, array $fileConfig): void |
145 | 145 | { |
146 | - $filePath = $fileConfig['path'] . DS . $file; |
|
146 | + $filePath = $fileConfig[ 'path' ].DS.$file; |
|
147 | 147 | |
148 | 148 | if (is_file($filePath)) { |
149 | 149 | // Check installed image library |
150 | - if (!extension_loaded($fileConfig['library'])) { |
|
151 | - throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $fileConfig['library'])); |
|
150 | + if (!extension_loaded($fileConfig[ 'library' ])) { |
|
151 | + throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $fileConfig[ 'library' ])); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // Get extension from original file |
155 | 155 | $fileExtension = $this->getExtension($file); |
156 | 156 | |
157 | - $fileConfig['library'] = mb_strtolower($fileConfig['library']); |
|
157 | + $fileConfig[ 'library' ] = mb_strtolower($fileConfig[ 'library' ]); |
|
158 | 158 | |
159 | - switch ($fileConfig['library']) { |
|
159 | + switch ($fileConfig[ 'library' ]) { |
|
160 | 160 | // Get image resource |
161 | 161 | case 'gd': |
162 | 162 | switch ($fileExtension) { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | break; |
200 | 200 | default: |
201 | - throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $fileConfig['library'])); |
|
201 | + throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $fileConfig[ 'library' ])); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | $offsetX = 0; |
@@ -207,47 +207,47 @@ discard block |
||
207 | 207 | $cropX = 0; |
208 | 208 | $cropY = 0; |
209 | 209 | |
210 | - foreach ($fileConfig['thumbs'] as $thumbName => $thumbConfig) { |
|
211 | - if (isset($thumbConfig['width'])) { |
|
212 | - list($newWidth, $newHeight) = $this->getDimensionsByNewWidth($originalWidth, $originalHeight, $thumbConfig['width']); |
|
213 | - } elseif (isset($thumbConfig['height'])) { |
|
214 | - list($newWidth, $newHeight) = $this->getDimensionsByNewHeight($originalWidth, $originalHeight, $thumbConfig['height']); |
|
215 | - } elseif (isset($thumbConfig['shorter']) && is_array($thumbConfig['shorter']) && count($thumbConfig['shorter']) === 2) { |
|
216 | - list($newWidth, $newHeight) = $this->getDimensionsByShorterSide($originalWidth, $originalHeight, $thumbConfig['shorter'][0], $thumbConfig['shorter'][1]); |
|
217 | - } elseif (isset($thumbConfig['longer']) && is_array($thumbConfig['longer']) && count($thumbConfig['longer']) === 2) { |
|
218 | - list($newWidth, $newHeight) = $this->getDimensionsByLongerSide($originalWidth, $originalHeight, $thumbConfig['longer'][0], $thumbConfig['longer'][1]); |
|
219 | - } elseif (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']) && count($thumbConfig['fit']) === 2) { |
|
220 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig['fit'][0], $thumbConfig['fit'][1]); |
|
221 | - } elseif (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']) && count($thumbConfig['fit']) === 3) { |
|
222 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig['fit'][0], $thumbConfig['fit'][1], $thumbConfig['fit'][2]); |
|
223 | - } elseif (isset($thumbConfig['square']) && is_array($thumbConfig['square']) && count($thumbConfig['square']) === 1) { |
|
224 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig['square'][0]); |
|
225 | - } elseif (isset($thumbConfig['square']) && is_array($thumbConfig['square']) && count($thumbConfig['square']) === 2) { |
|
226 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig['square'][0], $thumbConfig['square'][1]); |
|
210 | + foreach ($fileConfig[ 'thumbs' ] as $thumbName => $thumbConfig) { |
|
211 | + if (isset($thumbConfig[ 'width' ])) { |
|
212 | + list($newWidth, $newHeight) = $this->getDimensionsByNewWidth($originalWidth, $originalHeight, $thumbConfig[ 'width' ]); |
|
213 | + } elseif (isset($thumbConfig[ 'height' ])) { |
|
214 | + list($newWidth, $newHeight) = $this->getDimensionsByNewHeight($originalWidth, $originalHeight, $thumbConfig[ 'height' ]); |
|
215 | + } elseif (isset($thumbConfig[ 'shorter' ]) && is_array($thumbConfig[ 'shorter' ]) && count($thumbConfig[ 'shorter' ]) === 2) { |
|
216 | + list($newWidth, $newHeight) = $this->getDimensionsByShorterSide($originalWidth, $originalHeight, $thumbConfig[ 'shorter' ][ 0 ], $thumbConfig[ 'shorter' ][ 1 ]); |
|
217 | + } elseif (isset($thumbConfig[ 'longer' ]) && is_array($thumbConfig[ 'longer' ]) && count($thumbConfig[ 'longer' ]) === 2) { |
|
218 | + list($newWidth, $newHeight) = $this->getDimensionsByLongerSide($originalWidth, $originalHeight, $thumbConfig[ 'longer' ][ 0 ], $thumbConfig[ 'longer' ][ 1 ]); |
|
219 | + } elseif (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]) && count($thumbConfig[ 'fit' ]) === 2) { |
|
220 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig[ 'fit' ][ 0 ], $thumbConfig[ 'fit' ][ 1 ]); |
|
221 | + } elseif (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]) && count($thumbConfig[ 'fit' ]) === 3) { |
|
222 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig[ 'fit' ][ 0 ], $thumbConfig[ 'fit' ][ 1 ], $thumbConfig[ 'fit' ][ 2 ]); |
|
223 | + } elseif (isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ]) && count($thumbConfig[ 'square' ]) === 1) { |
|
224 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig[ 'square' ][ 0 ]); |
|
225 | + } elseif (isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ]) && count($thumbConfig[ 'square' ]) === 2) { |
|
226 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig[ 'square' ][ 0 ], $thumbConfig[ 'square' ][ 1 ]); |
|
227 | 227 | } else { |
228 | 228 | throw new ThumbsException(__d('file', 'Unknown type or incorrect parameters of creating thumbnails!')); |
229 | 229 | } |
230 | 230 | |
231 | 231 | $thumbFile = str_replace('default', $thumbName, $filePath); |
232 | 232 | |
233 | - switch ($fileConfig['library']) { |
|
233 | + switch ($fileConfig[ 'library' ]) { |
|
234 | 234 | // Get image resource |
235 | 235 | case 'gd': |
236 | 236 | $newImage = imagecreatetruecolor($newWidth, $newHeight); |
237 | 237 | |
238 | - if (is_array($fileConfig['background'])) { |
|
238 | + if (is_array($fileConfig[ 'background' ])) { |
|
239 | 239 | // Set background color and transparent indicates |
240 | - imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $fileConfig['background'][0], $fileConfig['background'][1], $fileConfig['background'][2], $fileConfig['background'][3])); |
|
240 | + imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $fileConfig[ 'background' ][ 0 ], $fileConfig[ 'background' ][ 1 ], $fileConfig[ 'background' ][ 2 ], $fileConfig[ 'background' ][ 3 ])); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | imagecopyresampled($newImage, $sourceImage, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight); |
244 | 244 | |
245 | - if ((isset($thumbConfig['square']) && is_array($thumbConfig['square'])) || (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']))) { |
|
245 | + if ((isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ])) || (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]))) { |
|
246 | 246 | $fitImage = imagecreatetruecolor($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY)); |
247 | 247 | |
248 | - if (is_array($fileConfig['background'])) { |
|
248 | + if (is_array($fileConfig[ 'background' ])) { |
|
249 | 249 | // Set background color and transparent indicates |
250 | - imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $fileConfig['background'][0], $fileConfig['background'][1], $fileConfig['background'][2], $fileConfig['background'][3])); |
|
250 | + imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $fileConfig[ 'background' ][ 0 ], $fileConfig[ 'background' ][ 1 ], $fileConfig[ 'background' ][ 2 ], $fileConfig[ 'background' ][ 3 ])); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | imagecopyresampled($fitImage, $newImage, $offsetX, $offsetY, $cropX, $cropY, $newWidth, $newHeight, $newWidth, $newHeight); |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | imagesavealpha($newImage, true); |
260 | 260 | |
261 | 261 | // Watermark |
262 | - if (isset($thumbConfig['watermark']) && ($watermarkSource = file_get_contents($fileConfig['watermark'])) !== false) { |
|
262 | + if (isset($thumbConfig[ 'watermark' ]) && ($watermarkSource = file_get_contents($fileConfig[ 'watermark' ])) !== false) { |
|
263 | 263 | $watermarkImage = imagecreatefromstring($watermarkSource); |
264 | 264 | |
265 | - list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbConfig['watermark']); |
|
265 | + list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbConfig[ 'watermark' ]); |
|
266 | 266 | |
267 | 267 | // Set transparent |
268 | 268 | imagealphablending($newImage, true); |
@@ -301,16 +301,16 @@ discard block |
||
301 | 301 | $newImage->setimagebackgroundcolor('transparent'); |
302 | 302 | $newImage->extentimage($newWidth + (2 * $offsetX), $newHeight + (2 * $offsetY), -$offsetX, -$offsetY); |
303 | 303 | |
304 | - if ((isset($thumbConfig['square']) && is_array($thumbConfig['square'])) || (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']))) { |
|
304 | + if ((isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ])) || (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]))) { |
|
305 | 305 | $newImage->cropimage($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY), $cropX, $cropY); |
306 | 306 | } |
307 | 307 | |
308 | 308 | // Watermark |
309 | - if (isset($thumbConfig['watermark']) && ($watermarkSource = file_get_contents($fileConfig['watermark'])) !== false) { |
|
309 | + if (isset($thumbConfig[ 'watermark' ]) && ($watermarkSource = file_get_contents($fileConfig[ 'watermark' ])) !== false) { |
|
310 | 310 | $watermarkImage = new \Imagick(); |
311 | 311 | $watermarkImage->readimageblob($watermarkSource); |
312 | 312 | |
313 | - list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbConfig['watermark']); |
|
313 | + list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbConfig[ 'watermark' ]); |
|
314 | 314 | |
315 | 315 | $newImage->compositeimage($watermarkImage, \Imagick::COMPOSITE_OVER, $watermarkPositionX, $watermarkPositionY); |
316 | 316 | } |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | |
340 | 340 | if (!empty($config)) { |
341 | 341 | foreach ($config as $file => $fileConfig) { |
342 | - if (isset($entity[$file])) { |
|
343 | - $path = $fileConfig['path'] . DS . substr($entity[$file], 0, 37); |
|
342 | + if (isset($entity[ $file ])) { |
|
343 | + $path = $fileConfig[ 'path' ].DS.substr($entity[ $file ], 0, 37); |
|
344 | 344 | |
345 | - foreach (glob($path . '*') as $file) { |
|
345 | + foreach (glob($path.'*') as $file) { |
|
346 | 346 | if (file_exists($file)) { |
347 | 347 | unlink($file); |
348 | 348 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | */ |
373 | 373 | protected function setFile(string $file, UploadedFile $data): void |
374 | 374 | { |
375 | - $this->files[$file] = $data; |
|
375 | + $this->files[ $file ] = $data; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | */ |
414 | 414 | protected function createName(string $name): string |
415 | 415 | { |
416 | - return Text::uuid() . '_default.' . $this->getExtension($name); |
|
416 | + return Text::uuid().'_default.'.$this->getExtension($name); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -458,43 +458,43 @@ discard block |
||
458 | 458 | { |
459 | 459 | switch ($positionValue) { |
460 | 460 | case 1: // Top left |
461 | - return [$offsetX, $offsetY]; |
|
461 | + return [ $offsetX, $offsetY ]; |
|
462 | 462 | |
463 | 463 | break; |
464 | 464 | case 2: // Top center |
465 | - return [($newWidth / 2) - ($watermarkWidth / 2), $offsetY]; |
|
465 | + return [ ($newWidth / 2) - ($watermarkWidth / 2), $offsetY ]; |
|
466 | 466 | |
467 | 467 | break; |
468 | 468 | case 3: // Top right |
469 | - return [($newWidth - $watermarkWidth - $offsetX), $offsetY]; |
|
469 | + return [ ($newWidth - $watermarkWidth - $offsetX), $offsetY ]; |
|
470 | 470 | |
471 | 471 | break; |
472 | 472 | case 4: // Middle left |
473 | - return [$offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2))]; |
|
473 | + return [ $offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2)) ]; |
|
474 | 474 | |
475 | 475 | break; |
476 | 476 | case 5: // Middle center |
477 | - return [intval(($newWidth / 2) - ($watermarkWidth / 2)), intval(($newHeight / 2) - ($watermarkHeight / 2))]; |
|
477 | + return [ intval(($newWidth / 2) - ($watermarkWidth / 2)), intval(($newHeight / 2) - ($watermarkHeight / 2)) ]; |
|
478 | 478 | |
479 | 479 | break; |
480 | 480 | case 6: // Middle right |
481 | - return [($newWidth - $watermarkWidth) - $offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2))]; |
|
481 | + return [ ($newWidth - $watermarkWidth) - $offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2)) ]; |
|
482 | 482 | |
483 | 483 | break; |
484 | 484 | case 7: // Bottom left |
485 | - return [$offsetX, ($newHeight - $watermarkHeight) - $offsetY]; |
|
485 | + return [ $offsetX, ($newHeight - $watermarkHeight) - $offsetY ]; |
|
486 | 486 | |
487 | 487 | break; |
488 | 488 | case 8: // Bottom center |
489 | - return [intval(($newWidth / 2) - ($watermarkWidth / 2)), ($newHeight - $watermarkHeight) - $offsetY]; |
|
489 | + return [ intval(($newWidth / 2) - ($watermarkWidth / 2)), ($newHeight - $watermarkHeight) - $offsetY ]; |
|
490 | 490 | |
491 | 491 | break; |
492 | 492 | case 9: // Bottom right |
493 | - return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY]; |
|
493 | + return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY ]; |
|
494 | 494 | |
495 | 495 | break; |
496 | 496 | default: |
497 | - return [$offsetX, $offsetY]; |
|
497 | + return [ $offsetX, $offsetY ]; |
|
498 | 498 | |
499 | 499 | break; |
500 | 500 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $newHeight = intval($newWidth * ($originalHeight / $originalWidth)); |
518 | 518 | } |
519 | 519 | |
520 | - return [$newWidth, $newHeight]; |
|
520 | + return [ $newWidth, $newHeight ]; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | $newWidth = intval($newHeight * ($originalWidth / $originalHeight)); |
538 | 538 | } |
539 | 539 | |
540 | - return [$newWidth, $newHeight]; |
|
540 | + return [ $newWidth, $newHeight ]; |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | /** |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | list($newWidth, $newHeight) = self::getDimensionsByNewHeight($originalWidth, $originalHeight, $newHeight); |
558 | 558 | } |
559 | 559 | |
560 | - return [$newWidth, $newHeight]; |
|
560 | + return [ $newWidth, $newHeight ]; |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | /** |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | list($newWidth, $newHeight) = self::getDimensionsByNewHeight($originalWidth, $originalHeight, $newHeight); |
578 | 578 | } |
579 | 579 | |
580 | - return [$newWidth, $newHeight]; |
|
580 | + return [ $newWidth, $newHeight ]; |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | } else { |
604 | 604 | $newSizes = self::getDimensionsByLongerSide($originalWidth, $originalHeight, $newWidth, $newHeight); |
605 | 605 | |
606 | - if ($newWidth < $newSizes[0] || $newHeight < $newSizes[1]) { |
|
606 | + if ($newWidth < $newSizes[ 0 ] || $newHeight < $newSizes[ 1 ]) { |
|
607 | 607 | $newSizes = self::getDimensionsByShorterSide($originalWidth, $originalHeight, $newWidth, $newHeight); |
608 | 608 | } |
609 | 609 | } |
@@ -613,25 +613,25 @@ discard block |
||
613 | 613 | } else { |
614 | 614 | $newSizes = self::getDimensionsByShorterSide($originalWidth, $originalHeight, $newWidth, $newHeight); |
615 | 615 | |
616 | - if ($newWidth > $newSizes[0] || $newHeight > $newSizes[1]) { |
|
616 | + if ($newWidth > $newSizes[ 0 ] || $newHeight > $newSizes[ 1 ]) { |
|
617 | 617 | $newSizes = self::getDimensionsByLongerSide($originalWidth, $originalHeight, $newWidth, $newHeight); |
618 | 618 | } |
619 | 619 | } |
620 | 620 | } |
621 | 621 | |
622 | - if ($newWidth < $newSizes[0]) { |
|
623 | - $cropX = ($newSizes[0] - $newWidth) / 2; |
|
622 | + if ($newWidth < $newSizes[ 0 ]) { |
|
623 | + $cropX = ($newSizes[ 0 ] - $newWidth) / 2; |
|
624 | 624 | } else { |
625 | - $offsetX = ($newWidth - $newSizes[0]) / 2; |
|
625 | + $offsetX = ($newWidth - $newSizes[ 0 ]) / 2; |
|
626 | 626 | } |
627 | 627 | |
628 | - if ($newHeight < $newSizes[1]) { |
|
629 | - $cropY = ($newSizes[1] - $newHeight) / 2; |
|
628 | + if ($newHeight < $newSizes[ 1 ]) { |
|
629 | + $cropY = ($newSizes[ 1 ] - $newHeight) / 2; |
|
630 | 630 | } else { |
631 | - $offsetY = ($newHeight - $newSizes[1]) / 2; |
|
631 | + $offsetY = ($newHeight - $newSizes[ 1 ]) / 2; |
|
632 | 632 | } |
633 | 633 | |
634 | - return [$newSizes[0], $newSizes[1], intval($offsetX), intval($offsetY), intval($cropX), intval($cropY)]; |
|
634 | + return [ $newSizes[ 0 ], $newSizes[ 1 ], intval($offsetX), intval($offsetY), intval($cropX), intval($cropY) ]; |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
@@ -676,6 +676,6 @@ discard block |
||
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
679 | - return [$newWidth, $newHeight, intval($offsetX), intval($offsetY), intval($cropX), intval($cropY)]; |
|
679 | + return [ $newWidth, $newHeight, intval($offsetX), intval($offsetY), intval($cropX), intval($cropY) ]; |
|
680 | 680 | } |
681 | 681 | } |
682 | 682 | \ No newline at end of file |