@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $index->fileExists = 0; |
111 | 111 | $transforms->storeTransformIndexData($index); |
112 | 112 | $volume = $asset->getVolume(); |
113 | - $transformPath = $asset->folderPath . $transforms->getTransformSubpath($asset, $index); |
|
113 | + $transformPath = $asset->folderPath.$transforms->getTransformSubpath($asset, $index); |
|
114 | 114 | try { |
115 | 115 | $volume->deleteFile($transformPath); |
116 | 116 | } catch (\Throwable $exception) { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $msg = 'Failed to update transform: '.$e->getMessage(); |
120 | 120 | Craft::error($msg, __METHOD__); |
121 | 121 | if (Craft::$app instanceof ConsoleApplication) { |
122 | - echo $msg . PHP_EOL; |
|
122 | + echo $msg.PHP_EOL; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | __METHOD__ |
141 | 141 | ); |
142 | 142 | if (Craft::$app instanceof ConsoleApplication) { |
143 | - echo $msg . PHP_EOL; |
|
143 | + echo $msg.PHP_EOL; |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $folder = $asset->getFolder(); |
201 | 201 | while ($folder !== null && !$createVariants) { |
202 | 202 | if ($folder->uid === $subfolder) { |
203 | - Craft::info('Matched subfolder uid: ' . print_r($subfolder, true), __METHOD__); |
|
203 | + Craft::info('Matched subfolder uid: '.print_r($subfolder, true), __METHOD__); |
|
204 | 204 | $createVariants = true; |
205 | 205 | } else { |
206 | 206 | $folder = $folder->getParent(); |
@@ -478,20 +478,20 @@ discard block |
||
478 | 478 | } |
479 | 479 | $useAspectRatio = $variant['useAspectRatio'] ?? false; |
480 | 480 | if ($useAspectRatio) { |
481 | - $aspectRatio = (int)$variant['aspectRatioX'] / (int)$variant['aspectRatioY']; |
|
481 | + $aspectRatio = (int) $variant['aspectRatioX'] / (int) $variant['aspectRatioY']; |
|
482 | 482 | } else { |
483 | - $aspectRatio = (int)$asset->width / (int)$asset->height; |
|
483 | + $aspectRatio = (int) $asset->width / (int) $asset->height; |
|
484 | 484 | } |
485 | - $width = (int)$variant['width'] * (int)$retinaSize; |
|
485 | + $width = (int) $variant['width'] * (int) $retinaSize; |
|
486 | 486 | $transform->width = $width; |
487 | - $transform->height = (int)($width / $aspectRatio); |
|
487 | + $transform->height = (int) ($width / $aspectRatio); |
|
488 | 488 | // Image quality |
489 | - $quality = (int)($variant['quality'] ?? null); |
|
489 | + $quality = (int) ($variant['quality'] ?? null); |
|
490 | 490 | if (empty($quality)) { |
491 | 491 | $quality = null; |
492 | 492 | } |
493 | 493 | if ($quality !== null && $settings->lowerQualityRetinaImageVariants && $retinaSize != '1') { |
494 | - $quality = (int)($quality * (1.5 / (int)$retinaSize)); |
|
494 | + $quality = (int) ($quality * (1.5 / (int) $retinaSize)); |
|
495 | 495 | } |
496 | 496 | $transform->quality = $quality; |
497 | 497 | // Interlaced (progressive JPEGs or interlaced PNGs) |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | ); |
89 | 89 | $result = ''; |
90 | 90 | $width = self::PLACEHOLDER_WIDTH; |
91 | - $height = (int)($width / $aspectRatio); |
|
91 | + $height = (int) ($width / $aspectRatio); |
|
92 | 92 | $placeholderPath = $this->createImageFromPath($tempPath, $width, $height, self::PLACEHOLDER_QUALITY, $position); |
93 | 93 | if (!empty($placeholderPath)) { |
94 | 94 | $result = base64_encode(file_get_contents($placeholderPath)); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | { |
111 | 111 | Craft::beginProfile('generateColorPalette', __METHOD__); |
112 | 112 | Craft::info( |
113 | - 'Generating color palette for: ' . $tempPath, |
|
113 | + 'Generating color palette for: '.$tempPath, |
|
114 | 114 | __METHOD__ |
115 | 115 | ); |
116 | 116 | $colorPalette = []; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $lightness /= $colorCount; |
157 | 157 | } |
158 | 158 | |
159 | - return $lightness === null ? $lightness : (int)$lightness; |
|
159 | + return $lightness === null ? $lightness : (int) $lightness; |
|
160 | 160 | } |
161 | 161 | /** |
162 | 162 | * Generate an SVG image via Potrace |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | __METHOD__ |
220 | 220 | ); |
221 | 221 | $width = self::TEMP_PLACEHOLDER_WIDTH; |
222 | - $height = (int)($width / $aspectRatio); |
|
222 | + $height = (int) ($width / $aspectRatio); |
|
223 | 223 | $tempPath = $this->createImageFromAsset($asset, $width, $height, self::TEMP_PLACEHOLDER_QUALITY, $position); |
224 | 224 | Craft::endProfile('createTempPlaceholderImage', __METHOD__); |
225 | 225 |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | while ($currentElement < $totalElements) { |
92 | 92 | $elements = $paginator->getPageResults(); |
93 | 93 | if (Craft::$app instanceof ConsoleApplication) { |
94 | - echo 'Query ' . $paginator->getCurrentPage() . '/' . $paginator->getTotalPages() |
|
95 | - . ' - assets: ' . $paginator->getTotalResults() |
|
94 | + echo 'Query '.$paginator->getCurrentPage().'/'.$paginator->getTotalPages() |
|
95 | + . ' - assets: '.$paginator->getTotalResults() |
|
96 | 96 | . PHP_EOL; |
97 | 97 | } |
98 | 98 | /** @var ElementInterface $element */ |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | if ($field instanceof OptimizedImagesField && $element instanceof Asset) { |
108 | 108 | if ($this->fieldId === null || $field->id == $this->fieldId) { |
109 | 109 | if (Craft::$app instanceof ConsoleApplication) { |
110 | - echo $currentElement . '/' . $totalElements |
|
111 | - . ' - processing asset: ' . $element->title |
|
112 | - . ' from field: ' . $field->name . PHP_EOL; |
|
110 | + echo $currentElement.'/'.$totalElements |
|
111 | + . ' - processing asset: '.$element->title |
|
112 | + . ' from field: '.$field->name.PHP_EOL; |
|
113 | 113 | } |
114 | 114 | try { |
115 | 115 | ImageOptimize::$plugin->optimizedImages->updateOptimizedImageFieldData($field, $element, $this->force); |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | echo '[error]: ' |
120 | 120 | . $e->getMessage() |
121 | 121 | . ' while processing ' |
122 | - . $currentElement . '/' . $totalElements |
|
123 | - . ' - processing asset: ' . $element->title |
|
124 | - . ' from field: ' . $field->name . PHP_EOL; |
|
122 | + . $currentElement.'/'.$totalElements |
|
123 | + . ' - processing asset: '.$element->title |
|
124 | + . ' from field: '.$field->name.PHP_EOL; |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | Event::on( |
234 | 234 | CraftVariable::class, |
235 | 235 | CraftVariable::EVENT_INIT, |
236 | - function (Event $event) { |
|
236 | + function(Event $event) { |
|
237 | 237 | /** @var CraftVariable $variable */ |
238 | 238 | $variable = $event->sender; |
239 | 239 | $variable->set('imageOptimize', ImageOptimizeVariable::class); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | Event::on( |
245 | 245 | Fields::class, |
246 | 246 | Fields::EVENT_REGISTER_FIELD_TYPES, |
247 | - function (RegisterComponentTypesEvent $event) { |
|
247 | + function(RegisterComponentTypesEvent $event) { |
|
248 | 248 | Craft::debug( |
249 | 249 | 'Fields::EVENT_REGISTER_FIELD_TYPES', |
250 | 250 | __METHOD__ |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | Event::on( |
258 | 258 | Utilities::class, |
259 | 259 | Utilities::EVENT_REGISTER_UTILITY_TYPES, |
260 | - function (RegisterComponentTypesEvent $event) { |
|
260 | + function(RegisterComponentTypesEvent $event) { |
|
261 | 261 | $event->types[] = ImageOptimizeUtility::class; |
262 | 262 | } |
263 | 263 | ); |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | Event::on( |
294 | 294 | Assets::class, |
295 | 295 | Assets::EVENT_GET_ASSET_URL, |
296 | - function (GetAssetUrlEvent $event) { |
|
296 | + function(GetAssetUrlEvent $event) { |
|
297 | 297 | Craft::debug( |
298 | 298 | 'Assets::EVENT_GET_ASSET_URL', |
299 | 299 | __METHOD__ |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | Event::on( |
310 | 310 | Assets::class, |
311 | 311 | Assets::EVENT_GET_ASSET_THUMB_URL, |
312 | - function (GetAssetThumbUrlEvent $event) { |
|
312 | + function(GetAssetThumbUrlEvent $event) { |
|
313 | 313 | Craft::debug( |
314 | 314 | 'Assets::EVENT_GET_ASSET_THUMB_URL', |
315 | 315 | __METHOD__ |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | Event::on( |
326 | 326 | AssetTransforms::class, |
327 | 327 | AssetTransforms::EVENT_GENERATE_TRANSFORM, |
328 | - function (GenerateTransformEvent $event) { |
|
328 | + function(GenerateTransformEvent $event) { |
|
329 | 329 | Craft::debug( |
330 | 330 | 'AssetTransforms::EVENT_GENERATE_TRANSFORM', |
331 | 331 | __METHOD__ |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | Event::on( |
342 | 342 | AssetTransforms::class, |
343 | 343 | AssetTransforms::EVENT_AFTER_DELETE_TRANSFORMS, |
344 | - function (AssetTransformImageEvent $event) { |
|
344 | + function(AssetTransformImageEvent $event) { |
|
345 | 345 | Craft::debug( |
346 | 346 | 'AssetTransforms::EVENT_AFTER_DELETE_TRANSFORMS', |
347 | 347 | __METHOD__ |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | Event::on( |
358 | 358 | Assets::class, |
359 | 359 | Assets::EVENT_BEFORE_REPLACE_ASSET, |
360 | - function (ReplaceAssetEvent $event) { |
|
360 | + function(ReplaceAssetEvent $event) { |
|
361 | 361 | Craft::debug( |
362 | 362 | 'Assets::EVENT_BEFORE_REPLACE_ASSET', |
363 | 363 | __METHOD__ |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | Event::on( |
377 | 377 | Assets::class, |
378 | 378 | Assets::EVENT_AFTER_REPLACE_ASSET, |
379 | - function (ReplaceAssetEvent $event) { |
|
379 | + function(ReplaceAssetEvent $event) { |
|
380 | 380 | Craft::debug( |
381 | 381 | 'Assets::EVENT_AFTER_REPLACE_ASSET', |
382 | 382 | __METHOD__ |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | Event::on( |
400 | 400 | Assets::class, |
401 | 401 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
402 | - function (ElementEvent $event) { |
|
402 | + function(ElementEvent $event) { |
|
403 | 403 | Craft::debug( |
404 | 404 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
405 | 405 | __METHOD__ |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | Event::on( |
421 | 421 | Asset::class, |
422 | 422 | Elements::EVENT_BEFORE_DELETE_ELEMENT, |
423 | - function (ElementEvent $event) { |
|
423 | + function(ElementEvent $event) { |
|
424 | 424 | Craft::debug( |
425 | 425 | 'Elements::EVENT_BEFORE_DELETE_ELEMENT', |
426 | 426 | __METHOD__ |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | Event::on( |
446 | 446 | Fields::class, |
447 | 447 | Fields::EVENT_AFTER_SAVE_FIELD, |
448 | - function (FieldEvent $event) { |
|
448 | + function(FieldEvent $event) { |
|
449 | 449 | Craft::debug( |
450 | 450 | 'Fields::EVENT_AFTER_SAVE_FIELD', |
451 | 451 | __METHOD__ |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | Event::on( |
463 | 463 | Plugins::class, |
464 | 464 | Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS, |
465 | - function (PluginEvent $event) { |
|
465 | + function(PluginEvent $event) { |
|
466 | 466 | if ($event->plugin === $this) { |
467 | 467 | Craft::debug( |
468 | 468 | 'Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS', |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | Event::on( |
482 | 482 | Volumes::class, |
483 | 483 | Volumes::EVENT_AFTER_SAVE_VOLUME, |
484 | - function (VolumeEvent $event) { |
|
484 | + function(VolumeEvent $event) { |
|
485 | 485 | Craft::debug( |
486 | 486 | 'Volumes::EVENT_AFTER_SAVE_VOLUME', |
487 | 487 | __METHOD__ |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | Event::on( |
503 | 503 | Plugins::class, |
504 | 504 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
505 | - function (PluginEvent $event) { |
|
505 | + function(PluginEvent $event) { |
|
506 | 506 | if ($event->plugin === $this) { |
507 | 507 | $request = Craft::$app->getRequest(); |
508 | 508 | if ($request->isCpRequest) { |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | Event::on( |
537 | 537 | UrlManager::class, |
538 | 538 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
539 | - function (RegisterUrlRulesEvent $event) { |
|
539 | + function(RegisterUrlRulesEvent $event) { |
|
540 | 540 | Craft::debug( |
541 | 541 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
542 | 542 | __METHOD__ |
@@ -559,12 +559,12 @@ discard block |
||
559 | 559 | Event::on( |
560 | 560 | Plugins::class, |
561 | 561 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
562 | - function () { |
|
562 | + function() { |
|
563 | 563 | // Install these only after all other plugins have loaded |
564 | 564 | Event::on( |
565 | 565 | View::class, |
566 | 566 | View::EVENT_REGISTER_CP_TEMPLATE_ROOTS, |
567 | - function (RegisterTemplateRootsEvent $e) { |
|
567 | + function(RegisterTemplateRootsEvent $e) { |
|
568 | 568 | // Register the root directodies |
569 | 569 | $allImageTransformTypes = ImageOptimize::$plugin->optimize->getAllImageTransformTypes(); |
570 | 570 | /** @var ImageTransformInterface $imageTransformType */ |