Use original image for srcset when it is small (#474)

This commit is contained in:
onli 2020-05-28 17:50:39 +02:00
parent 5d67e35f24
commit 2be8e6ba2a
2 changed files with 12 additions and 0 deletions

View File

@ -1,3 +1,9 @@
* Make it possible for plugins to let the core skip the check
whether trackbacks are already sent, with
$serendipity['skip_trackback_check']
* Add the original image to the response images srcset when
the original image is small, to avoid upscaling
Version 2.4-alpha1 ()
------------------------------------------------------------------------

View File

@ -216,6 +216,12 @@ class serendipity_event_responsiveimages extends serendipity_event
$srcset .= "{$thumbnailHttp} {$breakpoint}w,";
}
}
// 2 == there is the original thumbnail without a dimension, and one thumbnail for the smallest breakpoint
if (count($thumbnails) == 2) {
// When the smallest thumbnail is the only responsive thumbnail our original image will be needed to as part of the srcset, otherwise we too often upscale the small thumbnail
$srcset .= "$imagePath {$origImage['dimensions_width']}w,";
}
if (substr($srcset, -strlen(',')) === ',') {
// we don't want to have the trailing comma
$srcset = substr($srcset, 0, -1);