[Resolved] Adding class to disable lazyload on featured image

Home Forums Support [Resolved] Adding class to disable lazyload on featured image

Home Forums Support Adding class to disable lazyload on featured image

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1416287
    Tan

    Hi there,
    I follow this guide to disable lazyload on featured image (on top every post).
    I’m wanting to add the class “skip-lazy” to all featured images on my blog.
    What could I do?
    Thank for your help!

    #1416344
    Leo
    Staff
    Customer Support
    #1416830
    Tan

    Thank you Leo.
    After adding that snippet I can’t see class through Chrome.
    Could you visit my post and check it out? It’s here.

    I have a snippet to adding feature image through shortcode.

    function db_feat_img_shortcode() {
        $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'hero', false );
    	return '<img src="' . $img_src[0] . '"/>';
    }
    add_shortcode( 'db_feat_img', 'db_feat_img_shortcode' );

    And also have a hook to show them on blog.

    #1417225
    David
    Staff
    Customer Support

    Hi there,

    in your function – you can change this line:

    return '<img src="' . $img_src[0] . '"/>';

    to this:

    return '<img src="' . $img_src[0] . '" class="skip-lazy" />';

    #1417647
    Tan

    It worked.
    Thank you so much David 🙂

    #1417908
    David
    Staff
    Customer Support

    You’re welcome

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.