diff --git a/classes/TagGenerator.php b/classes/TagGenerator.php index 950c702..0f7f280 100644 --- a/classes/TagGenerator.php +++ b/classes/TagGenerator.php @@ -128,6 +128,9 @@ class TagGenerator { $sizes = collect(explode('|', $sizes)); $minSize = $sizes->shift(); + $sizes = $sizes->sortByDesc(function($size) { + return explode(':', $size)[0]; + }); return $sizes->map(function($size) { $components = explode(':', $size); diff --git a/tests/ImageTagTest.php b/tests/ImageTagTest.php index bda3648..a576886 100644 --- a/tests/ImageTagTest.php +++ b/tests/ImageTagTest.php @@ -181,7 +181,7 @@ class ImageTagTest extends TestCase $output = app(Twig::class)->parse('{{ "/pages/test.jpg" | resize("original", "1rem|200:10px|500:20px") }}'); - $this->assertStringContainsString('sizes="(min-width: 200px) 10px, (min-width: 500px) 20px, 1rem"', $output); + $this->assertStringContainsString('sizes="(min-width: 500px) 20px, (min-width: 200px) 10px, 1rem"', $output); } public function testItGeneratesOnlySingleImage()