skip to Main Content

is there a code to disable lazy loading on just the site logo in WordPress?

2

Answers


  1. you can exclude that image from the plugin that you are using for lazy loading.

    Login or Signup to reply.
  2. 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 );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search