[WP Rocket]How To Disable LazyLoad on Specific Images

jkrolling

New member
May 3, 2019
21
8
3
you can do this either by using data-skip-lazy atribute or add skip-lazy to the header css class
 

jkrolling

New member
May 3, 2019
21
8
3
you can either do this :


<img src="yourheaderlogo.jpg" class="skip-lazy" alt="" width="100" width="100" />

or

checkout the above link i posted to target a specific class
 

videva

Member
Aug 25, 2020
75
53
18
I tried it but can you please tell what changes I need to implement in code.
I don't want the image name "main-logo" to lazy load.
what theme are you using ??
just edit header.php find your img logo code change to this
<img src="your-logo-image.jpg" data-skip-lazy="" class="skip-lazy" alt="" />
 

videva

Member
Aug 25, 2020
75
53
18
This code breaks my layout.
if so, edit the header.php in wp-content/themes/generatepress/inc/structure
then follow the steps below
PHP:
//1. find header-image in header.php
//you will see code like this
$attr = apply_filters( 'generate_logo_attributes', array(
            'class' => 'header-image',
            'alt'    => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
            'src'    => $logo_url,
            'title'    => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
        ) );
   
//then replace the code above with the code below
$attr = apply_filters( 'generate_logo_attributes', array(
            'class' => 'skip-lazy header-image',
            'data-skip-lazy' => '',
            'alt'    => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
            'src'    => $logo_url,
            'title'    => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
        ) );
//save and refresh you homepage.

#result like this, i'm using generatepress theme without elementor plugin.
dd.png

If this doesn't work then you should Assigning class to Element in Elementor
-add skip-lazy class to logo element
 
Last edited:

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu