From d71a87a4f5c43a2602a5d5f7dba3506a370e41c0 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Mon, 11 Jul 2022 13:16:14 -0400 Subject: [PATCH 1/6] fix: Fixed an issue where transforms don't get deleted on remote volumes if the format was set to `auto` ([#341](https://github.com/nystudio107/craft-imageoptimize/issues/341)) --- src/services/Optimize.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/Optimize.php b/src/services/Optimize.php index cea11a4..2dfbca1 100644 --- a/src/services/Optimize.php +++ b/src/services/Optimize.php @@ -804,6 +804,7 @@ protected function cleanupImageVariants(Asset $asset, AssetTransformIndex $trans // Get the active image variant creators $activeImageVariantCreators = $settings->activeImageVariantCreators; $fileFormat = $transformIndex->detectedFormat ?? $transformIndex->format ?? $asset->getExtension(); + $fileFormat = empty($fileFormat) ? $asset->getExtension() : $fileFormat; if (!empty($activeImageVariantCreators[$fileFormat])) { // Iterate through all the image variant creators for this format $imageVariantCreators = $settings->imageVariantCreators; From 9583b67d33ecedeb461d9a7a1c1134e29976aaee Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Mon, 11 Jul 2022 13:16:24 -0400 Subject: [PATCH 2/6] chore: Version 4.0.2 --- CHANGELOG.md | 6 +++++- composer.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b81d852..88ab11e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # ImageOptimize Changelog +## 4.0.2 - UNRELEASED +### Fixed +* Fixed an issue where transforms don't get deleted on remote volumes if the format was set to `auto` ([#341](https://github.com/nystudio107/craft-imageoptimize/issues/341)) + ## 4.0.1 - 2022.07.08 ### Fixed * If there's no transform requested, return `null` so other plugins have a crack at it ([#349](https://github.com/nystudio107/craft-imageoptimize/issues/349)) @@ -11,7 +15,7 @@ * If there's no transform requested, and we're not using some external service for image transforms, return `null` so other plugins have a crack at it ### Fixed -* Set the variant format to the current asset format if it is left empty, otherwise Craft recursively calls `getTransformUrl()` and hangs the queue ([#329]https://github.com/nystudio107/craft-imageoptimize/issues/329) ([#343](https://github.com/nystudio107/craft-imageoptimize/issues/343)) +* Set the variant format to the current asset format if it is left empty, otherwise Craft recursively calls `getTransformUrl()` and hangs the queue ([#329](https://github.com/nystudio107/craft-imageoptimize/issues/329)) ([#343](https://github.com/nystudio107/craft-imageoptimize/issues/343)) * Fixed an issue where variants would not resave under certain circumstance due to a typing issue ([#335](https://github.com/nystudio107/craft-imageoptimize/issues/335)) * Make the properties in the `OptimizedImage` nullable to avoid null property values throwing an exception ([#345](https://github.com/nystudio107/craft-imageoptimize/issues/345)) * Fixed an issue that caused sub-folders to not appear in the OptimizedImages field settings ([#333](https://github.com/nystudio107/craft-imageoptimize/issues/333)) diff --git a/composer.json b/composer.json index 2dd2c49..d6bb0e2 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "nystudio107/craft-imageoptimize", "description": "Automatically create & optimize responsive image transforms, using either native Craft transforms or a service like imgix, with zero template changes.", "type": "craft-plugin", - "version": "4.0.1", + "version": "4.0.2", "keywords": [ "craft", "cms", From 3bd8e7d3621e74a80afa01c3d44143e17b2d6834 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Wed, 13 Jul 2022 12:52:51 -0700 Subject: [PATCH 3/6] fix: fix: Normalize for lowercase file extensions and normalize `jpeg` -> `jpg` everywhere --- src/services/Optimize.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/services/Optimize.php b/src/services/Optimize.php index 2dfbca1..1dab02b 100644 --- a/src/services/Optimize.php +++ b/src/services/Optimize.php @@ -175,8 +175,14 @@ public function handleGetAssetUrlEvent(DefineAssetUrlEvent $event): ?string $imageTransforms = Craft::$app->getImageTransforms(); $transform = $imageTransforms->getTransformByHandle($transform); } - // If the final format is an SVG, don't attempt to transform it $finalFormat = empty($transform['format']) ? $asset->getExtension() : $transform['format']; + // Normalize the extension to lowercase, for some transform methods that require this + $finalFormat = strtolower($finalFormat); + // Special-case for 'jpeg' + if ($finalFormat === 'jpeg') { + $finalFormat = 'jpg'; + } + // If the final format is an SVG, don't attempt to transform it if ($finalFormat === 'svg') { return null; } @@ -217,15 +223,17 @@ public function handleGetAssetThumbUrlEvent(DefineAssetThumbUrlEvent $event): ?s ]); /** @var ImageTransform $transformMethod */ $transformMethod = ImageOptimize::$plugin->transformMethod; - // If the final format is an SVG, don't attempt to transform it $finalFormat = empty($transform['format']) ? $asset->getExtension() : $transform['format']; + // Normalize the extension to lowercase, for some transform methods that require this + $finalFormat = strtolower($finalFormat); + // Special-case for 'jpeg' + if ($finalFormat === 'jpeg') { + $finalFormat = 'jpg'; + } + // If the final format is an SVG, don't attempt to transform it if ($finalFormat === 'svg') { return null; } - // Normalize the extension to lowercase, for some transform methods that require this - if (!empty($finalFormat)) { - $transform['format'] = strtolower($finalFormat); - } // Generate an image transform url if ($transformMethod->hasProperty('generateTransformsBeforePageLoad')) { $transformMethod->generateTransformsBeforePageLoad = true; @@ -805,6 +813,12 @@ protected function cleanupImageVariants(Asset $asset, AssetTransformIndex $trans $activeImageVariantCreators = $settings->activeImageVariantCreators; $fileFormat = $transformIndex->detectedFormat ?? $transformIndex->format ?? $asset->getExtension(); $fileFormat = empty($fileFormat) ? $asset->getExtension() : $fileFormat; + // Normalize the extension to lowercase, for some transform methods that require this + $fileFormat = strtolower($fileFormat); + // Special-case for 'jpeg' + if ($fileFormat === 'jpeg') { + $fileFormat = 'jpg'; + } if (!empty($activeImageVariantCreators[$fileFormat])) { // Iterate through all the image variant creators for this format $imageVariantCreators = $settings->imageVariantCreators; From 36506afb97dbc282247d209174bcd87746a871c8 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Wed, 13 Jul 2022 12:52:58 -0700 Subject: [PATCH 4/6] chore: Version 4.0.2 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88ab11e..dd5ea24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 4.0.2 - UNRELEASED ### Fixed * Fixed an issue where transforms don't get deleted on remote volumes if the format was set to `auto` ([#341](https://github.com/nystudio107/craft-imageoptimize/issues/341)) +* Normalize for lowercase file extensions and normalize `jpeg` -> `jpg` everywhere ## 4.0.1 - 2022.07.08 ### Fixed From 8880a730173902231b463a687bb8852f7ec7eda9 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Sun, 17 Jul 2022 13:25:07 -0700 Subject: [PATCH 5/6] refactor: Add `allow-plugins` to `composer.json` to allow CI tests to work --- composer.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/composer.json b/composer.json index d6bb0e2..134ef1f 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,14 @@ "ksubileau/color-thief-php": "^1.3", "mikehaertl/php-shellcommand": "~1.2" }, + "config": { + "allow-plugins": { + "craftcms/plugin-installer": true, + "yiisoft/yii2-composer": true + }, + "optimize-autoloader": true, + "sort-packages": true + }, "autoload": { "psr-4": { "nystudio107\\imageoptimize\\": "src/" From 8ab0606ab6fd7f726e6cedf226165598580ad405 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Sun, 17 Jul 2022 13:27:11 -0700 Subject: [PATCH 6/6] chore: Version 4.0.2 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd5ea24..b818287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # ImageOptimize Changelog -## 4.0.2 - UNRELEASED +## 4.0.2 - 2022.07.17 +### Changed +* Add `allow-plugins` to `composer.json` to allow CI tests to work + ### Fixed * Fixed an issue where transforms don't get deleted on remote volumes if the format was set to `auto` ([#341](https://github.com/nystudio107/craft-imageoptimize/issues/341)) * Normalize for lowercase file extensions and normalize `jpeg` -> `jpg` everywhere