@@ -59,7 +59,7 @@ |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | if (!is_file($path)) { |
62 | - Craft::error('Tried to load an image at ' . $path . ', but the file does not exist.', __METHOD__); |
|
62 | + Craft::error('Tried to load an image at '.$path.', but the file does not exist.', __METHOD__); |
|
63 | 63 | throw new ImageException(Craft::t('app', 'No file exists at the given path.')); |
64 | 64 | } |
65 | 65 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $model->addError( |
42 | 42 | $attribute, |
43 | 43 | Craft::t('image-optimize', 'Object failed to validate') |
44 | - . '-' . $attributeError . ' - ' . $valueError |
|
44 | + . '-'.$attributeError.' - '.$valueError |
|
45 | 45 | ); |
46 | 46 | } |
47 | 47 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return ?ImageTransformInterface The Image Transform |
121 | 121 | */ |
122 | - public function createImageTransformType(string|array $config): ?ImageTransformInterface |
|
122 | + public function createImageTransformType(string | array $config): ?ImageTransformInterface |
|
123 | 123 | { |
124 | 124 | if (is_string($config)) { |
125 | 125 | $config = ['type' => $config]; |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | . '%'; |
389 | 389 | Craft::info($message, __METHOD__); |
390 | 390 | if (Craft::$app instanceof ConsoleApplication) { |
391 | - echo $message . PHP_EOL; |
|
391 | + echo $message.PHP_EOL; |
|
392 | 392 | } |
393 | 393 | // Create any image variants |
394 | 394 | $this->createImageVariants( |
@@ -426,14 +426,14 @@ discard block |
||
426 | 426 | */ |
427 | 427 | public function saveTransformToTempFile(AssetTransformIndex $index, Image $image): string |
428 | 428 | { |
429 | - $tempFilename = uniqid(pathinfo($index->filename, PATHINFO_FILENAME), true) . '.' . $index->detectedFormat; |
|
430 | - $tempPath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $tempFilename; |
|
429 | + $tempFilename = uniqid(pathinfo($index->filename, PATHINFO_FILENAME), true).'.'.$index->detectedFormat; |
|
430 | + $tempPath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$tempFilename; |
|
431 | 431 | try { |
432 | 432 | $image->saveAs($tempPath); |
433 | 433 | } catch (ImageException $e) { |
434 | - Craft::error('Transformed image save failed: ' . $e->getMessage(), __METHOD__); |
|
434 | + Craft::error('Transformed image save failed: '.$e->getMessage(), __METHOD__); |
|
435 | 435 | } |
436 | - Craft::info('Transformed image saved to: ' . $tempPath, __METHOD__); |
|
436 | + Craft::info('Transformed image saved to: '.$tempPath, __METHOD__); |
|
437 | 437 | |
438 | 438 | return $tempPath; |
439 | 439 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | . '%'; |
547 | 547 | Craft::info($message, __METHOD__); |
548 | 548 | if (Craft::$app instanceof ConsoleApplication) { |
549 | - echo $message . PHP_EOL; |
|
549 | + echo $message.PHP_EOL; |
|
550 | 550 | } |
551 | 551 | // Copy the image variant into place |
552 | 552 | $this->copyImageVariantToVolume( |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | // Handle auto-sharpening scaled down images |
645 | 645 | if ($imagineImage !== null && $settings->autoSharpenScaledImages) { |
646 | 646 | // See if the image has been scaled >= 50% |
647 | - $widthScale = (int)(($image->getWidth() / $asset->getWidth()) * 100); |
|
648 | - $heightScale = (int)(($image->getHeight() / $asset->getHeight()) * 100); |
|
647 | + $widthScale = (int) (($image->getWidth() / $asset->getWidth()) * 100); |
|
648 | + $heightScale = (int) (($image->getHeight() / $asset->getHeight()) * 100); |
|
649 | 649 | if (($widthScale >= $settings->sharpenScaledImagePercentage) || ($heightScale >= $settings->sharpenScaledImagePercentage)) { |
650 | 650 | $imagineImage->effects() |
651 | 651 | ->sharpen(); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | . escapeshellarg($tempPath); |
701 | 701 | // Execute the command |
702 | 702 | $shellOutput = $this->executeShellCommand($cmd); |
703 | - Craft::info($cmd . "\n" . $shellOutput, __METHOD__); |
|
703 | + Craft::info($cmd."\n".$shellOutput, __METHOD__); |
|
704 | 704 | } else { |
705 | 705 | Craft::error( |
706 | 706 | $thisProcessor['commandPath'] |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | // Make sure the command exists |
753 | 753 | if (is_file($variantCreatorCommand['commandPath'])) { |
754 | 754 | // Get the output file for this image variant |
755 | - $outputPath .= '.' . $variantCreatorCommand['imageVariantExtension']; |
|
755 | + $outputPath .= '.'.$variantCreatorCommand['imageVariantExtension']; |
|
756 | 756 | // Set any options for the command |
757 | 757 | $commandOptions = ''; |
758 | 758 | if (!empty($variantCreatorCommand['commandOptions'])) { |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | . escapeshellarg($tempPath); |
788 | 788 | // Execute the command |
789 | 789 | $shellOutput = $this->executeShellCommand($cmd); |
790 | - Craft::info($cmd . "\n" . $shellOutput, __METHOD__); |
|
790 | + Craft::info($cmd."\n".$shellOutput, __METHOD__); |
|
791 | 791 | } else { |
792 | 792 | Craft::error( |
793 | 793 | $variantCreatorCommand['commandPath'] |
@@ -832,17 +832,17 @@ discard block |
||
832 | 832 | } catch (InvalidConfigException $invalidConfigException) { |
833 | 833 | $fs = null; |
834 | 834 | Craft::error( |
835 | - 'Asset file system error: ' . $invalidConfigException->getMessage(), |
|
835 | + 'Asset file system error: '.$invalidConfigException->getMessage(), |
|
836 | 836 | __METHOD__ |
837 | 837 | ); |
838 | 838 | } |
839 | 839 | |
840 | - $variantPath = $uri . '.' . $variantCreatorCommand['imageVariantExtension']; |
|
840 | + $variantPath = $uri.'.'.$variantCreatorCommand['imageVariantExtension']; |
|
841 | 841 | |
842 | 842 | // Delete the variant file in case it is stale |
843 | 843 | $fs->deleteFile($variantPath); |
844 | 844 | Craft::info( |
845 | - 'Deleted variant: ' . $variantPath, |
|
845 | + 'Deleted variant: '.$variantPath, |
|
846 | 846 | __METHOD__ |
847 | 847 | ); |
848 | 848 | } |
@@ -875,17 +875,17 @@ discard block |
||
875 | 875 | } catch (InvalidConfigException $e) { |
876 | 876 | $fs = null; |
877 | 877 | Craft::error( |
878 | - 'Asset volume error: ' . $e->getMessage(), |
|
878 | + 'Asset volume error: '.$e->getMessage(), |
|
879 | 879 | __METHOD__ |
880 | 880 | ); |
881 | 881 | } |
882 | 882 | |
883 | - $variantPath = $uri . '.' . $variantCreatorCommand['imageVariantExtension']; |
|
883 | + $variantPath = $uri.'.'.$variantCreatorCommand['imageVariantExtension']; |
|
884 | 884 | |
885 | 885 | // Delete the variant file in case it is stale |
886 | 886 | $fs->deleteFile($variantPath); |
887 | 887 | Craft::info( |
888 | - 'Variant output path: ' . $outputPath . ' - Variant path: ' . $variantPath, |
|
888 | + 'Variant output path: '.$outputPath.' - Variant path: '.$variantPath, |
|
889 | 889 | __METHOD__ |
890 | 890 | ); |
891 | 891 | clearstatcache(true, $outputPath); |
@@ -913,9 +913,9 @@ discard block |
||
913 | 913 | protected function swapPathExtension(string $path, string $extension): string |
914 | 914 | { |
915 | 915 | $pathParts = pathinfo($path); |
916 | - $newPath = $pathParts['filename'] . '.' . $extension; |
|
916 | + $newPath = $pathParts['filename'].'.'.$extension; |
|
917 | 917 | if (!empty($pathParts['dirname']) && $pathParts['dirname'] !== '.') { |
918 | - $newPath = $pathParts['dirname'] . DIRECTORY_SEPARATOR . $newPath; |
|
918 | + $newPath = $pathParts['dirname'].DIRECTORY_SEPARATOR.$newPath; |
|
919 | 919 | $newPath = preg_replace('#/+#', '/', $newPath); |
920 | 920 | } |
921 | 921 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return string|null |
47 | 47 | */ |
48 | - public function getTransformUrl(Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string; |
|
48 | + public function getTransformUrl(Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Return a URL to the webp version of the transformed image |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return ?string |
58 | 58 | */ |
59 | - public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string; |
|
59 | + public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Return the URL that should be used to purge the Asset |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * @inheritDoc |
59 | 59 | */ |
60 | - public function getTransformUrl(Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string |
|
60 | + public function getTransformUrl(Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string |
|
61 | 61 | { |
62 | 62 | // Generate the URLs to the optimized images |
63 | 63 | $oldValue = Craft::$app->getConfig()->getGeneral()->generateTransformsBeforePageLoad; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * @inheritDoc |
76 | 76 | */ |
77 | - public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string |
|
77 | + public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string |
|
78 | 78 | { |
79 | 79 | return $this->appendExtension($url, '.webp'); |
80 | 80 | } |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | if (strlen($htmlCode) === 3) { |
40 | - $htmlCode = $htmlCode[0] . $htmlCode[0] . $htmlCode[1] . $htmlCode[1] . $htmlCode[2] . $htmlCode[2]; |
|
40 | + $htmlCode = $htmlCode[0].$htmlCode[0].$htmlCode[1].$htmlCode[1].$htmlCode[2].$htmlCode[2]; |
|
41 | 41 | } |
42 | 42 | |
43 | - $r = hexdec($htmlCode[0] . $htmlCode[1]); |
|
44 | - $g = hexdec($htmlCode[2] . $htmlCode[3]); |
|
45 | - $b = hexdec($htmlCode[4] . $htmlCode[5]); |
|
43 | + $r = hexdec($htmlCode[0].$htmlCode[1]); |
|
44 | + $g = hexdec($htmlCode[2].$htmlCode[3]); |
|
45 | + $b = hexdec($htmlCode[4].$htmlCode[5]); |
|
46 | 46 | |
47 | 47 | return ['r' => $r, 'g' => $g, 'b' => $b]; |
48 | 48 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public static function RGBToHSL(array $rgb): array |
58 | 58 | { |
59 | - $r = ((float)$rgb['r']) / 255.0; |
|
60 | - $g = ((float)$rgb['g']) / 255.0; |
|
61 | - $b = ((float)$rgb['b']) / 255.0; |
|
59 | + $r = ((float) $rgb['r']) / 255.0; |
|
60 | + $g = ((float) $rgb['g']) / 255.0; |
|
61 | + $b = ((float) $rgb['b']) / 255.0; |
|
62 | 62 | |
63 | 63 | $maxC = max($r, $g, $b); |
64 | 64 | $minC = min($r, $g, $b); |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | $h /= 6.0; |
87 | 87 | } |
88 | 88 | |
89 | - $h = (int)round(360.0 * $h); |
|
90 | - $s = (int)round(100.0 * $s); |
|
91 | - $l = (int)round(100.0 * $l); |
|
89 | + $h = (int) round(360.0 * $h); |
|
90 | + $s = (int) round(100.0 * $s); |
|
91 | + $l = (int) round(100.0 * $l); |
|
92 | 92 | |
93 | 93 | return ['h' => $h, 's' => $s, 'l' => $l]; |
94 | 94 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function actionCreate(?string $volumeHandle = null): void |
74 | 74 | { |
75 | - echo 'Creating optimized image variants' . PHP_EOL; |
|
75 | + echo 'Creating optimized image variants'.PHP_EOL; |
|
76 | 76 | if ($this->force) { |
77 | - echo 'Forcing optimized image variants creation via --force' . PHP_EOL; |
|
77 | + echo 'Forcing optimized image variants creation via --force'.PHP_EOL; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $fieldId = null; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | if ($volume) { |
93 | 93 | ImageOptimize::$plugin->optimizedImages->resaveVolumeAssets($volume, $fieldId, $this->force); |
94 | 94 | } else { |
95 | - echo 'Unknown Asset Volume handle: ' . $volumeHandle . PHP_EOL; |
|
95 | + echo 'Unknown Asset Volume handle: '.$volumeHandle.PHP_EOL; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | if (!$this->queue) { |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function actionCreateAsset(?int $id = null): void |
109 | 109 | { |
110 | - echo 'Creating optimized image variants' . PHP_EOL; |
|
110 | + echo 'Creating optimized image variants'.PHP_EOL; |
|
111 | 111 | |
112 | 112 | if ($id === null) { |
113 | - echo 'No Asset ID specified' . PHP_EOL; |
|
113 | + echo 'No Asset ID specified'.PHP_EOL; |
|
114 | 114 | } else { |
115 | 115 | // Re-save a single Asset ID |
116 | 116 | ImageOptimize::$plugin->optimizedImages->resaveAsset($id, $this->force); |
@@ -5,7 +5,7 @@ |
||
5 | 5 | |
6 | 6 | return static function(ECSConfig $ecsConfig): void { |
7 | 7 | $ecsConfig->paths([ |
8 | - __DIR__ . '/src', |
|
8 | + __DIR__.'/src', |
|
9 | 9 | __FILE__, |
10 | 10 | ]); |
11 | 11 | $ecsConfig->parallel(); |
@@ -279,6 +279,6 @@ |
||
279 | 279 | public static function getName($context = null): string |
280 | 280 | { |
281 | 281 | /** @var OptimizedImages $context */ |
282 | - return $context->handle . '_OptimizedImages'; |
|
282 | + return $context->handle.'_OptimizedImages'; |
|
283 | 283 | } |
284 | 284 | } |