Skip to content

Commit

Permalink
Merge branch 'release/1.6.48' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jul 17, 2022
2 parents 0276804 + 0af1917 commit b5a7193
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
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": "1.6.47",
"version": "1.6.48",
"keywords": [
"craft",
"cms",
Expand Down Expand Up @@ -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/"
Expand Down
23 changes: 21 additions & 2 deletions src/services/Optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b5a7193

Please sign in to comment.