-
Hi,
I want to disable lazy loading of the featured image in each post. I am currently using Smush to lazy load images and they have an option to disable by class or id.How do I create a class for all featured images?
-
Fernando
Hi there,
For reference, can you share a link to a post on your site? We’ll assess what needs to be done after seeing a Post on your site.
-
Yes, here is a link.
-
Fernando
Try this snippet to add
post-featured-imageto the class list of all Featured images:function add_class_first_featured_image($attr) { global $wp_query; if ( 0 == $wp_query->current_post ) { $attr['class'] .= ' post-featured-image'; } return $attr; } add_filter('wp_get_attachment_image_attributes', 'add_class_first_featured_image' );Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
-
Ok I did that and then excluded the class in Smush.
Can you tell if it worked? -
Fernando
I can see that the class has now been added.
If you’ve added this class to Smush, it should work.
Viewing 6 posts - 1 through 6 (of 6 total)
- You must be logged in to reply to this topic.