From cf428f35495dd602b5520cebc6df7bcfef50f1b1 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Fri, 14 Jun 2024 13:49:48 -0700 Subject: [PATCH 1/6] fix: Fixed an issue where `srcsetMaxWidth()` could return incorrect results ([#407](https://github.com/nystudio107/craft-imageoptimize/issues/407)) --- src/models/OptimizedImage.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/models/OptimizedImage.php b/src/models/OptimizedImage.php index 32c2133..43a3972 100644 --- a/src/models/OptimizedImage.php +++ b/src/models/OptimizedImage.php @@ -618,6 +618,9 @@ protected function getSrcsetSubsetArray(array $set, int $width, string $comparis if (empty($this->variantSourceWidths)) { return $subset; } + // Sort the arrays by numeric key + ksort($set, SORT_NUMERIC); + ksort($this->variantSourceWidths, SORT_NUMERIC); foreach ($this->variantSourceWidths as $variantSourceWidth) { $match = false; switch ($comparison) { From 829faf314d6d5829dedac73ef99ef00a548d6f81 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Fri, 14 Jun 2024 13:50:35 -0700 Subject: [PATCH 2/6] chore: Version 5.0.2 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d3a868..ee6ed03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # ImageOptimize Changelog +## 5.0.2 - UNRELEASED +### Fixed +* Fixed an issue where `srcsetMaxWidth()` could return incorrect results ([#407](https://github.com/nystudio107/craft-imageoptimize/issues/407)) + ## 5.0.1 - 2024.05.09 ### Fixed * Fixed an issue where field content was not propagated to other sites on multi-site installs, causing missing images diff --git a/composer.json b/composer.json index e139e47..af72d9e 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": "5.0.1", + "version": "5.0.2", "keywords": [ "craft", "cms", From db1c1fe99c60e438fd0c8b5fe6eff81c478e9ca7 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Mon, 17 Jun 2024 13:18:54 -0400 Subject: [PATCH 3/6] fix: Sort by value, not by key for `variantSourceWidths` --- src/models/OptimizedImage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/OptimizedImage.php b/src/models/OptimizedImage.php index 43a3972..3480446 100644 --- a/src/models/OptimizedImage.php +++ b/src/models/OptimizedImage.php @@ -620,7 +620,7 @@ protected function getSrcsetSubsetArray(array $set, int $width, string $comparis } // Sort the arrays by numeric key ksort($set, SORT_NUMERIC); - ksort($this->variantSourceWidths, SORT_NUMERIC); + sort($this->variantSourceWidths, SORT_NUMERIC); foreach ($this->variantSourceWidths as $variantSourceWidth) { $match = false; switch ($comparison) { From c7c6d452598c963dc74d4eff1c141507d6ea0e27 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Mon, 17 Jun 2024 21:18:00 -0400 Subject: [PATCH 4/6] fix: Fixed an issue where the data-uri for inline SVG styles were incorrect in some browsers because the spaces were not URL-encoded ([#408](https://github.com/nystudio107/craft-imageoptimize/issues/408)) --- src/services/OptimizedImages.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/services/OptimizedImages.php b/src/services/OptimizedImages.php index 0878129..6b40830 100644 --- a/src/services/OptimizedImages.php +++ b/src/services/OptimizedImages.php @@ -429,8 +429,6 @@ public function encodeOptimizedSVGDataUri(string $uri): string $replacements = [ // remove newlines '/%0A/' => '', - // put spaces back in - '/%20/' => ' ', // put equals signs back in '/%3D/' => '=', // put colons back in From cd39930d6842cce95a69bc44723e66c230ab061a Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Mon, 17 Jun 2024 21:18:41 -0400 Subject: [PATCH 5/6] chore: Version 5.0.2 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee6ed03..6a09e74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 5.0.2 - UNRELEASED ### Fixed * Fixed an issue where `srcsetMaxWidth()` could return incorrect results ([#407](https://github.com/nystudio107/craft-imageoptimize/issues/407)) +* Fixed an issue where the data-uri for inline SVG styles were incorrect in some browsers because the spaces were not URL-encoded ([#408](https://github.com/nystudio107/craft-imageoptimize/issues/408)) ## 5.0.1 - 2024.05.09 ### Fixed From ddf20cc6e6cbfbb9a871add2534d7a4657737d74 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Wed, 19 Jun 2024 14:04:02 -0400 Subject: [PATCH 6/6] chore: Version 5.0.2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a09e74..2b68f2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # ImageOptimize Changelog -## 5.0.2 - UNRELEASED +## 5.0.2 - 2024.06.19 ### Fixed * Fixed an issue where `srcsetMaxWidth()` could return incorrect results ([#407](https://github.com/nystudio107/craft-imageoptimize/issues/407)) * Fixed an issue where the data-uri for inline SVG styles were incorrect in some browsers because the spaces were not URL-encoded ([#408](https://github.com/nystudio107/craft-imageoptimize/issues/408))