Disabling LazyLoad on Specific Images

In this Article

Disable LazyLoad on an image

If you want to disable LazyLoad on a specific image, you can do so by adding the
data-no-lazy attribute to the img HTML tag:

<img src="my-image.jpg" data-no-lazy="1" alt="" width="100" width="100" />

Disabling LazyLoad on an image class

You can target a specific class to exclude from LazyLoad by using the following:

function rocket_lazyload_exclude_class( $attributes ) {
	$attributes[] = 'class="divi-slider"';

	return $attributes;
}
add_filter( 'rocket_lazyload_excluded_attributes', 'rocket_lazyload_exclude_class' );

In $attributes, the class must exactly match the HTML markup. For example if the class on the image looks like this:

class="attachment-post-thumbnail size-post-thumbnail wp-post-image"
You must specify all attributes, like this:
$attributes[] = 'class="attachment-post-thumbnail size-post-thumbnail wp-post-image"';

Disabling LazyLoad by Image Src

You can target an image by its src, allowing you to exclude images from LazyLoad that are hosted on other domain. In the below example, images served from wp.com will be excluded from LazyLoad:

function rocket_lazyload_exclude_src( $src ) {
	$src[] = 'wp.com';

	return $src;
}
add_filter( 'rocket_lazyload_excluded_src', 'rocket_lazyload_exclude_src' );

Disabling LazyLoad on Avatars

If you want to disable Lazyload on your website's avatars, you can do so by adding this code to your    functions.php theme file:

remove_filter( 'get_avatar', 'rocket_lazyload_images', PHP_INT_MAX );