Disable lazy loading for images in AMP
authorAlexander Ebert <ebert@woltlab.com>
Tue, 15 Jun 2021 09:36:59 +0000 (11:36 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 15 Jun 2021 09:36:59 +0000 (11:36 +0200)
Fixes #4290

wcfsetup/install/files/lib/system/html/output/AmpHtmlOutputProcessor.class.php

index 645fb1c16079a6128db8195c284dc2f6e51f0b92..df4eb79bd4b3ebcc057b794ec9ff2cba09e61ff5 100644 (file)
@@ -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);
                 }