is there a code to disable lazy loading on just the site logo in WordPress?
CodePudding user response:
you can exclude that image from the plugin that you are using for lazy loading.
CodePudding user response:
You can disable Lazy Load on Specific Images by using the Hook Below
Place the Hook in your functions.php file
/* Disable lazy loading by image ID and size */
function wphelp_no_lazy_load_id( $value, $image, $context ) {
if ( 'the_content' === $context ) {
$image_url = wp_get_attachment_image_url( 4532, 'large' ); // Change the ID and size
if ( false !== strpos( $image, ' src="' . $image_url . '"' )) {
return false;
}
}
return $value;
}
add_filter( 'wp_img_tag_add_loading_attr', 'wphelp_no_lazy_load_id', 10, 3 );