• Was trying to figure out way to add a class only to my featured images in my Elementor layout for blog posts, so I can disable lazyload on them, and this plugin works great. Highly recommend it. That said, I ended up deciding not to use it since I found a Functions.php code snippet that worked for my needs. I prefer to not use additional plugins if I can help it. But if you need more granular control over classes on images and you use Elementor, this plugin is what you need.

    But if you just need to do what I did, here’s the snippet that worked for me:

    function db_add_class_to_single_featured_image($attr) {
        remove_filter('wp_get_attachment_image_attributes','db_add_class_to_single_featured_image');
        if ( is_single() ) {
            $attr['class'] .= ' no-lazy';
        }
        return $attr;
    }
    add_filter('wp_get_attachment_image_attributes','db_add_class_to_single_featured_image'); 
  • The topic ‘Works Great. Useful.’ is closed to new replies.