From: Alexander Ebert Date: Tue, 15 Jun 2021 09:36:59 +0000 (+0200) Subject: Disable lazy loading for images in AMP X-Git-Tag: 5.4.0_Beta_2~14 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c1e3cf9be668bac5c953ae5ce71c94c90ea7183b;p=GitHub%2FWoltLab%2FWCF.git Disable lazy loading for images in AMP Fixes #4290 --- diff --git a/wcfsetup/install/files/lib/system/html/output/AmpHtmlOutputProcessor.class.php b/wcfsetup/install/files/lib/system/html/output/AmpHtmlOutputProcessor.class.php index 645fb1c160..df4eb79bd4 100644 --- a/wcfsetup/install/files/lib/system/html/output/AmpHtmlOutputProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/output/AmpHtmlOutputProcessor.class.php @@ -91,6 +91,11 @@ class AmpHtmlOutputProcessor extends HtmlOutputProcessor for ($i = 0, $length = $element->attributes->length; $i < $length; $i++) { $attr = $element->attributes->item($i); + // AMP does not support lazy loading of images. + if ($tag === 'img' && $attr === 'loading') { + continue; + } + $newElement->setAttribute($attr->localName, $attr->nodeValue); }