@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | } catch (Throwable $exception) { |
| 126 | 126 | } |
| 127 | 127 | } catch (Throwable $e) { |
| 128 | - $msg = 'Failed to update transform: ' . $e->getMessage(); |
|
| 128 | + $msg = 'Failed to update transform: '.$e->getMessage(); |
|
| 129 | 129 | Craft::error($msg, __METHOD__); |
| 130 | 130 | if (Craft::$app instanceof ConsoleApplication) { |
| 131 | - echo $msg . PHP_EOL; |
|
| 131 | + echo $msg.PHP_EOL; |
|
| 132 | 132 | } |
| 133 | 133 | // Add the error message to the stickyErrors for the model |
| 134 | 134 | $model->stickyErrors[] = $msg; |
@@ -142,16 +142,16 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | } else { |
| 144 | 144 | $canManipulate = Image::canManipulateAsImage($asset->getExtension()); |
| 145 | - $msg = 'Could not create transform for: ' . $asset->title |
|
| 146 | - . ' - Final format: ' . $finalFormat |
|
| 147 | - . ' - Element extension: ' . $asset->getExtension() |
|
| 148 | - . ' - canManipulateAsImage: ' . $canManipulate; |
|
| 145 | + $msg = 'Could not create transform for: '.$asset->title |
|
| 146 | + . ' - Final format: '.$finalFormat |
|
| 147 | + . ' - Element extension: '.$asset->getExtension() |
|
| 148 | + . ' - canManipulateAsImage: '.$canManipulate; |
|
| 149 | 149 | Craft::error( |
| 150 | 150 | $msg, |
| 151 | 151 | __METHOD__ |
| 152 | 152 | ); |
| 153 | 153 | if (Craft::$app instanceof ConsoleApplication) { |
| 154 | - echo $msg . PHP_EOL; |
|
| 154 | + echo $msg.PHP_EOL; |
|
| 155 | 155 | } |
| 156 | 156 | if ($canManipulate) { |
| 157 | 157 | // Add the error message to the stickyErrors for the model |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | $this->addVariantImageToModel($asset, $model, $transform, $variant, $aspectRatio); |
| 182 | 182 | } else { |
| 183 | 183 | $canManipulate = Image::canManipulateAsImage($asset->getExtension()); |
| 184 | - $msg = 'Could not create transform for: ' . $asset->title |
|
| 185 | - . ' - Final format: ' . $finalFormat |
|
| 186 | - . ' - Element extension: ' . $asset->getExtension() |
|
| 187 | - . ' - canManipulateAsImage: ' . $canManipulate; |
|
| 184 | + $msg = 'Could not create transform for: '.$asset->title |
|
| 185 | + . ' - Final format: '.$finalFormat |
|
| 186 | + . ' - Element extension: '.$asset->getExtension() |
|
| 187 | + . ' - canManipulateAsImage: '.$canManipulate; |
|
| 188 | 188 | Craft::error( |
| 189 | 189 | $msg, |
| 190 | 190 | __METHOD__ |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $folder = $asset->getFolder(); |
| 224 | 224 | while ($folder !== null && !$createVariants) { |
| 225 | 225 | if ($folder->uid === $subfolder || $folder->name === $subfolder) { |
| 226 | - Craft::info('Matched subfolder uid: ' . print_r($subfolder, true), __METHOD__); |
|
| 226 | + Craft::info('Matched subfolder uid: '.print_r($subfolder, true), __METHOD__); |
|
| 227 | 227 | $createVariants = true; |
| 228 | 228 | } else { |
| 229 | 229 | $folder = $folder->getParent(); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | } catch (SiteNotFoundException $e) { |
| 342 | 342 | $siteId = 0; |
| 343 | 343 | Craft::error( |
| 344 | - 'Failed to get primary site: ' . $e->getMessage(), |
|
| 344 | + 'Failed to get primary site: '.$e->getMessage(), |
|
| 345 | 345 | __METHOD__ |
| 346 | 346 | ); |
| 347 | 347 | } |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | { |
| 446 | 446 | Craft::beginProfile('generatePlaceholders', __METHOD__); |
| 447 | 447 | Craft::info( |
| 448 | - 'generatePlaceholders for: ' . print_r($model, true), |
|
| 448 | + 'generatePlaceholders for: '.print_r($model, true), |
|
| 449 | 449 | __METHOD__ |
| 450 | 450 | ); |
| 451 | 451 | $settings = ImageOptimize::$plugin->getSettings(); |
@@ -503,20 +503,20 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | $useAspectRatio = $variant['useAspectRatio'] ?? false; |
| 505 | 505 | if ($useAspectRatio) { |
| 506 | - $aspectRatio = (float)$variant['aspectRatioX'] / (float)$variant['aspectRatioY']; |
|
| 506 | + $aspectRatio = (float) $variant['aspectRatioX'] / (float) $variant['aspectRatioY']; |
|
| 507 | 507 | } else { |
| 508 | - $aspectRatio = (float)$asset->width / (float)$asset->height; |
|
| 508 | + $aspectRatio = (float) $asset->width / (float) $asset->height; |
|
| 509 | 509 | } |
| 510 | - $width = (int)$variant['width'] * (int)$retinaSize; |
|
| 510 | + $width = (int) $variant['width'] * (int) $retinaSize; |
|
| 511 | 511 | $transform->width = $width; |
| 512 | - $transform->height = (int)($width / $aspectRatio); |
|
| 512 | + $transform->height = (int) ($width / $aspectRatio); |
|
| 513 | 513 | // Image quality |
| 514 | - $quality = (int)($variant['quality'] ?? null); |
|
| 514 | + $quality = (int) ($variant['quality'] ?? null); |
|
| 515 | 515 | if (empty($quality)) { |
| 516 | 516 | $quality = null; |
| 517 | 517 | } |
| 518 | 518 | if ($quality !== null && $settings->lowerQualityRetinaImageVariants && $retinaSize != '1') { |
| 519 | - $quality = (int)($quality * (1.5 / (int)$retinaSize)); |
|
| 519 | + $quality = (int) ($quality * (1.5 / (int) $retinaSize)); |
|
| 520 | 520 | } |
| 521 | 521 | $transform->quality = $quality; |
| 522 | 522 | // Interlaced (progressive JPEGs or interlaced PNGs) |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | $transform |
| 544 | 544 | ); |
| 545 | 545 | Craft::info( |
| 546 | - 'URL created: ' . print_r($url, true), |
|
| 546 | + 'URL created: '.print_r($url, true), |
|
| 547 | 547 | __METHOD__ |
| 548 | 548 | ); |
| 549 | 549 | // Update the model |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | $this->generatePlaceholders($asset, $model, $aspectRatio); |
| 572 | 572 | } |
| 573 | 573 | Craft::info( |
| 574 | - 'Created transforms for variant: ' . print_r($variant, true), |
|
| 574 | + 'Created transforms for variant: '.print_r($variant, true), |
|
| 575 | 575 | __METHOD__ |
| 576 | 576 | ); |
| 577 | 577 | } |
@@ -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 | } |