@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function actionCreate(?string $volumeHandle = null): void |
56 | 56 | { |
57 | - echo 'Creating optimized image variants' . PHP_EOL; |
|
57 | + echo 'Creating optimized image variants'.PHP_EOL; |
|
58 | 58 | if ($this->force) { |
59 | - echo 'Forcing optimized image variants creation via --force' . PHP_EOL; |
|
59 | + echo 'Forcing optimized image variants creation via --force'.PHP_EOL; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $fieldId = null; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | if ($volume) { |
75 | 75 | ImageOptimize::$plugin->optimizedImages->resaveVolumeAssets($volume, $fieldId, $this->force); |
76 | 76 | } else { |
77 | - echo 'Unknown Asset Volume handle: ' . $volumeHandle . PHP_EOL; |
|
77 | + echo 'Unknown Asset Volume handle: '.$volumeHandle.PHP_EOL; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | $this->runCraftQueue(); |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function actionCreateAsset(?int $id = null): void |
89 | 89 | { |
90 | - echo 'Creating optimized image variants' . PHP_EOL; |
|
90 | + echo 'Creating optimized image variants'.PHP_EOL; |
|
91 | 91 | |
92 | 92 | if ($id === null) { |
93 | - echo 'No Asset ID specified' . PHP_EOL; |
|
93 | + echo 'No Asset ID specified'.PHP_EOL; |
|
94 | 94 | } else { |
95 | 95 | // Re-save a single Asset ID |
96 | 96 | ImageOptimize::$plugin->optimizedImages->resaveAsset($id, $this->force); |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | return $this->defaultPlaceholderImage(); |
548 | 548 | } |
549 | 549 | |
550 | - return Template::raw($header . rawurlencode($content)); |
|
550 | + return Template::raw($header.rawurlencode($content)); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | return $this->defaultPlaceholderImage(); |
626 | 626 | } |
627 | 627 | |
628 | - return Template::raw($header . $content); |
|
628 | + return Template::raw($header.$content); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -753,16 +753,16 @@ discard block |
||
753 | 753 | foreach ($array as $key => $value) { |
754 | 754 | if ($dpr) { |
755 | 755 | $descriptor = '1x'; |
756 | - if (!empty($array[(int)$key / 2])) { |
|
756 | + if (!empty($array[(int) $key / 2])) { |
|
757 | 757 | $descriptor = '2x'; |
758 | 758 | } |
759 | - if (!empty($array[(int)$key / 3])) { |
|
759 | + if (!empty($array[(int) $key / 3])) { |
|
760 | 760 | $descriptor = '3x'; |
761 | 761 | } |
762 | 762 | } else { |
763 | - $descriptor = $key . 'w'; |
|
763 | + $descriptor = $key.'w'; |
|
764 | 764 | } |
765 | - $srcset .= $value . ' ' . $descriptor . ', '; |
|
765 | + $srcset .= $value.' '.$descriptor.', '; |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | return rtrim($srcset, ', '); |
@@ -796,13 +796,13 @@ discard block |
||
796 | 796 | { |
797 | 797 | // Set the class and loading attributes |
798 | 798 | if (isset($attrs['class'])) { |
799 | - $attrs['class'] = trim($attrs['class'] . ' lazyload'); |
|
799 | + $attrs['class'] = trim($attrs['class'].' lazyload'); |
|
800 | 800 | } |
801 | 801 | // Set the style on this element to be the placeholder image as the background-image |
802 | 802 | if (isset($attrs['style']) && !empty($attrs['src'])) { |
803 | 803 | $attrs['style'] = trim( |
804 | - $attrs['style'] . |
|
805 | - 'background-image:url(' . $this->getLazyLoadSrc($placeHolder) . '); background-size: cover;' |
|
804 | + $attrs['style']. |
|
805 | + 'background-image:url('.$this->getLazyLoadSrc($placeHolder).'); background-size: cover;' |
|
806 | 806 | ); |
807 | 807 | } |
808 | 808 | // Handle attributes that lazy and lazySizesFallback have in common |
@@ -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 |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * @inheritdoc |
66 | 66 | */ |
67 | - public function getTransformUrl(Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string |
|
67 | + public function getTransformUrl(Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string |
|
68 | 68 | { |
69 | 69 | return null; |
70 | 70 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @inheritdoc |
74 | 74 | */ |
75 | - public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string |
|
75 | + public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string |
|
76 | 76 | { |
77 | 77 | return $url; |
78 | 78 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | if ($volume->getFs()->subfolder ?? null) { |
107 | 107 | $subfolder = $volume->getFs()->subfolder; |
108 | 108 | $subfolder = Craft::parseEnv($subfolder); |
109 | - return rtrim($subfolder, '/') . '/' . $assetPath; |
|
109 | + return rtrim($subfolder, '/').'/'.$assetPath; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return $assetPath; |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | { |
144 | 144 | $path = $this->decomposeUrl($pathOrUrl); |
145 | 145 | $path_parts = pathinfo($path['path']); |
146 | - $new_path = ($path_parts['filename'] ?? '') . '.' . ($path_parts['extension'] ?? '') . $extension; |
|
146 | + $new_path = ($path_parts['filename'] ?? '').'.'.($path_parts['extension'] ?? '').$extension; |
|
147 | 147 | if (!empty($path_parts['dirname']) && $path_parts['dirname'] !== '.') { |
148 | 148 | $dirname = $path_parts['dirname']; |
149 | 149 | $dirname = $dirname === '/' ? '' : $dirname; |
150 | - $new_path = $dirname . DIRECTORY_SEPARATOR . $new_path; |
|
150 | + $new_path = $dirname.DIRECTORY_SEPARATOR.$new_path; |
|
151 | 151 | $new_path = preg_replace('/([^:])(\/{2,})/', '$1/', $new_path); |
152 | 152 | } |
153 | 153 | |
154 | - return $path['prefix'] . $new_path . $path['suffix']; |
|
154 | + return $path['prefix'].$new_path.$path['suffix']; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // Protected Methods |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | |
171 | 171 | if (filter_var($pathOrUrl, FILTER_VALIDATE_URL)) { |
172 | 172 | $url_parts = parse_url($pathOrUrl); |
173 | - $result['prefix'] = $url_parts['scheme'] . '://' . $url_parts['host']; |
|
173 | + $result['prefix'] = $url_parts['scheme'].'://'.$url_parts['host']; |
|
174 | 174 | if (!empty($url_parts['port'])) { |
175 | - $result['prefix'] .= ':' . $url_parts['port']; |
|
175 | + $result['prefix'] .= ':'.$url_parts['port']; |
|
176 | 176 | } |
177 | 177 | $result['path'] = $url_parts['path']; |
178 | 178 | $result['suffix'] = ''; |
179 | - $result['suffix'] .= empty($url_parts['query']) ? '' : '?' . $url_parts['query']; |
|
180 | - $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#' . $url_parts['fragment']; |
|
179 | + $result['suffix'] .= empty($url_parts['query']) ? '' : '?'.$url_parts['query']; |
|
180 | + $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#'.$url_parts['fragment']; |
|
181 | 181 | } else { |
182 | 182 | $result['prefix'] = ''; |
183 | 183 | $result['path'] = $pathOrUrl; |
@@ -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 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | // so we can't extract it from the passed in $config |
42 | 42 | $majorVersion = '4'; |
43 | 43 | // Dev server container name & port are based on the major version of this plugin |
44 | - $devPort = 3000 + (int)$majorVersion; |
|
45 | - $versionName = 'v' . $majorVersion; |
|
44 | + $devPort = 3000 + (int) $majorVersion; |
|
45 | + $versionName = 'v'.$majorVersion; |
|
46 | 46 | return [ |
47 | 47 | 'components' => [ |
48 | 48 | 'optimize' => OptimizeService::class, |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | 'assetClass' => ImageOptimizeAsset::class, |
54 | 54 | 'checkDevServer' => true, |
55 | 55 | 'class' => VitePluginService::class, |
56 | - 'devServerInternal' => 'http://craft-imageoptimize-' . $versionName . '-buildchain-dev:' . $devPort, |
|
57 | - 'devServerPublic' => 'http://localhost:' . $devPort, |
|
56 | + 'devServerInternal' => 'http://craft-imageoptimize-'.$versionName.'-buildchain-dev:'.$devPort, |
|
57 | + 'devServerPublic' => 'http://localhost:'.$devPort, |
|
58 | 58 | 'errorEntry' => 'src/js/ImageOptimize.js', |
59 | 59 | 'useDevServer' => true, |
60 | 60 | ], |