Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add noloading to all images in an AMP page
* Make sure that all <amp-img> elements have the noloading attribute.
class Img_Noloading_Sanitizer extends AMP_Base_Sanitizer {
public function sanitize() {
foreach ( $this->dom->getElementsByTagName( 'amp-img' ) as $img ) {
$img->setAttribute( 'noloading', '' );
add_filter( 'amp_content_sanitizers', function( $sanitizers ) {
require_once __DIR__ . '/class-img-noloading-sanitizer.php';
return array_merge(
'Img_Noloading_Sanitizer' => array(),
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.