• Resolved stocket

    (@alimohebbi)


    I want to exclude my website logo lazy loading but the img element of logo doesn’t have any class or identify to define it in smush class exclude section. also I don’t want to modify my theme’s code because when I update all modifications must be rewrite.
    Is it possible to define the image full URL or path for excluding of lazy loading? or define parent element class for exclusion?

    • This topic was modified 6 years, 2 months ago by stocket.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Laura – WPMU DEV Support

    (@wpmudev-support8)

    Hi @alimohebbi

    I hope you’re well today!

    Currently it’s only possible to exclude some media types entirely (e.g.jpg, .png), output locations (e.g. don’t use lazy load in widgets) or exclude entire pages/URLS (and that would mean all images on such page) or images by the ID/class – but it must be specifically related to image.

    A parent class will not work, I’m afraid, and it’s not possible to add image URL directly to be excluded.

    But there’s a filter built-in that should do the job and would let you exclude image by URL. You would want to add following code to the site either to your theme’s “functions.php” file or as an MU plugin

    add_filter( 'smush_skip_image_from_lazy_load', function( $skip, $src ){
    
    $skip_image = 'https://domain.com/myimage.jpg';
    	
    
    if ( $src == $skip_image ) {
    	return true;
    }
    
    return $skip;
    
    }, 20, 2 );

    Note: make sure to replace example URL in it with a real URL of the image you want to skip lazy load for.

    Best regards,
    Adam

    Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @alimohebbi

    I hope you are doing well!

    We haven’t heard back from you for a while now so we’ve marked this ticket as resolved. If you do have any followup questions or require further assistance feel free to reopen it and let us know here.

    Kind regards,
    Nastia

    Thread Starter stocket

    (@alimohebbi)

    Hello Nastia,
    your solution was perfect and it worked for me.
    thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Exclude images without class or identify’ is closed to new replies.