Archived topic
Lazy Load Logo not working
4 replies · Started by Amit on May 28, 2021
Hi, I want to add class 'skip-lazy' to my logo on desktop as well as on mobile. I tried with the following code in functions.php
`add_filter( 'generate_logo_output', 'tu_logo_class', 10, 3 );
function tu_logo_class( $output, $logo_url, $html_attr ) {
printf(
'
',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
$html_attr
);
}
But it didn't work out. Instead, the logo became bigger and aligned itself weird.
Hi there,
if thats WP Rocket Lazy Loading then try this snippet instead:
function rocket_lazyload_exclude_class( $attributes ) {
$attributes[] = 'class="is-logo-image"';
return $attributes;
}
add_filter( 'rocket_lazyload_excluded_attributes', 'rocket_lazyload_exclude_class' );
I use a plugin called 'Lazy Load by WP Rocket'. I inserted that function but the logo is still lazyloaded.
Finally, this function works
`function rocket_lazyload_exclude_src( $src ) {
$src[] = 'Image File Name Without extension';
return $src;
}
add_filter( 'rocket_lazyload_excluded_src', 'rocket_lazyload_exclude_src' );
Glad to hear you found a solution