getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.28k stars 167 forks source link

`$file->srcset()` includes upscaled image sizes #6495

Closed lukasbestle closed 3 months ago

lukasbestle commented 3 months ago

Description

If $file->srcset() gets passed one or multiple image width(s) that are larger than the source image, the resulting srcset string includes those sizes as well. The linked thumb is of course not upscaled, but the browser only knows after requesting the image.

Expected behavior

Widths that are larger than the source should be filtered out and the source width as maximum option should be added instead.

To reproduce

With a source image of 750px width

echo $file->srcset([300, 500, 1000, 1500]);

all those sizes are printed. Instead, the result should be 300, 500, 750.

Your setup

Kirby Version

develop branch

Additional context

Things to keep in mind:

lukasbestle commented 3 months ago

Duplicate of #2071 😅