Fixed: Order sizes from top to bottom

This commit is contained in:
philipp lang 2021-11-09 01:51:19 +01:00
parent bfb3ac206a
commit d8dacc6546
2 changed files with 4 additions and 1 deletions

View File

@ -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);

View File

@ -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()