Disable Lazy Loading | WordPress.org

[ad_1]

Hi,

Thank you for this great plugin.

[EDIT, SOLVED]

Sorry for the false alarm. It’s solved.

I was writing to ask if the image on the author page could have lazy-loading=”eager”, since it’s the largest contentful paint there.
But, my code was incorrect.
This is the edited, correct / working version.

// The avatar image is full size on the author page, but medum_large on other pages
// On the author page, lazy loading is disabled, because the avatar is the largest contentful paint
if ( is_author() ) {
	if (function_exists ( 'mt_profile_img' ) ) {
		$author_id = $post->post_author;
		$author_image = mt_profile_img( $author_id, array(
			'size' => 'full',
			'attr' => array( 'alt' => 'Author image', 'class' => 'avatar author-avatar', 'loading' => 'eager' ),
			'echo' => false )
		);
	}
} else {
	if (function_exists ( 'mt_profile_img' ) ) {
		$author_id = $post->post_author;
		$author_image = mt_profile_img( $author_id, array(
			'size' => 'medium_large',
			'attr' => array( 'alt' => 'Author image', 'class' => 'avatar author-avatar' ),
			'echo' => false )
		);
	}
}

echo $author_image;

Best regards,
Jovan

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer