Skip to content

Commit

Permalink
Merge branch 'release/4.0.2' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jul 17, 2022
2 parents 2c0648c + 8ab0606 commit 0cabbdb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ImageOptimize Changelog

## 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

## 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))
Expand All @@ -11,7 +19,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))
Expand Down
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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/"
Expand Down
27 changes: 21 additions & 6 deletions src/services/Optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -804,6 +812,13 @@ 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;
// 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;
Expand Down

0 comments on commit 0cabbdb

Please sign in to comment.