Set loading="lazy" to ML images if width and height are known

This commit is contained in:
onli 2021-06-05 18:23:36 +02:00
parent 8852792674
commit a96fe8040a
2 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,5 @@
* New images added via the ML will set loading="lazy", improving
site performance for visitors (only if height and width known)
* Remove multitude of wysiwyg toolbars
* PHP 8 compatibility for serendipity core
* Fix: Using the ML filters in the selection popup after uploading

View File

@ -331,7 +331,13 @@
if (floating == "") {
floating = "center";
}
img = "<!-- s9ymdb:" + imgID + " --><img class=\"serendipity_image_"+ floating +"\" width=\"" + imgWidth + "\" height=\"" + imgHeight + '" src="' + img + "\" " + (title != '' ? 'title="' + title + '"' : '') + " alt=\"" + alt + "\">";
var lazyload = '';
if (imgWidth && imgHeight) {
lazyload = 'loading="lazy"';
}
img = "<!-- s9ymdb:" + imgID + " --><img class=\"serendipity_image_"+ floating +"\" width=\"" + imgWidth + "\" height=\"" + imgHeight + '" src="' + img + "\" " + (title != '' ? 'title="' + title + '"' : '') + " " + lazyload + " alt=\"" + alt + "\">";
if ($(':input[name="serendipity[isLink]"]:checked').val() == "yes") {
// wrap the img in a link to the image. TODO: The label in the media_chooser.tpl explains it wrong