diff --git a/CHANGELOG.md b/CHANGELOG.md index b36c5b7..50acad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # ImageOptimize Changelog +## 1.6.48 - 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 + ## 1.6.47 - 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)) diff --git a/composer.json b/composer.json index 91eabc6..6bc8773 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": "1.6.47", + "version": "1.6.48", "keywords": [ "craft", "cms", @@ -36,6 +36,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/" diff --git a/src/services/Optimize.php b/src/services/Optimize.php index 281347b..eae75c5 100644 --- a/src/services/Optimize.php +++ b/src/services/Optimize.php @@ -173,8 +173,14 @@ public function handleGetAssetUrlEvent(GetAssetUrlEvent $event) $assetTransforms = Craft::$app->getAssetTransforms(); $transform = $assetTransforms->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; } @@ -215,8 +221,14 @@ public function handleGetAssetThumbUrlEvent(GetAssetThumbUrlEvent $event) ]); /** @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; } @@ -801,6 +813,13 @@ protected function cleanupImageVariants(Asset $asset, AssetTransformIndex $trans // Get the active image variant creators $activeImageVariantCreators = $settings->activeImageVariantCreators; $fileFormat = $transformIndex->detectedFormat ?? $transformIndex->format; + $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 of the image variant creators for this format $imageVariantCreators = $settings->imageVariantCreators;