- This topic has 7 replies, 3 voices, and was last updated 3 months, 1 week ago by David.
April 29, 2022 at 6:06 pm #2204466JP
I’m trying to add a css class (name = ‘featured-img-primary’) on featured images across all blog pages (here’s an example blog page – https://www.trendsandtactics.com/how-to-make-money-dancing). Can the team please advise how to accomplish this?
Thank you!April 29, 2022 at 9:21 pm #2204508LeoStaffCustomer Support
Hi there,April 30, 2022 at 6:47 am #2204725JP
I applied that code and it did not work. I think the blog post I linked might need a custom adjustment. It should also be noted there’s a picture tag and img tag for the featured image (I’d like the php to target the “img” tag not the picture tag).
*** overall request goal: once there’s a unique css class on the featured img tag, we’ll be able to target that image and exclude lazy loading (to help with page speed).
Best,April 30, 2022 at 8:13 am #2204942DavidStaffCustomer Support
that snippet Leo linked to will apply to the
Problem you may have is whatever plugin/service you’re using to create the webP versions is rewriting the Featured Image HTML.
If you can disable the webP on a single post and clear any caches you can check to see if that snippet is working.April 30, 2022 at 11:49 am #2205084JP
Thank you for helping me look into this!
I checked the plugin that’s creating Webp versions (Imagify), and there’s no way to disable on a single post. With that in mind, are there any other possible solutions?
Best,May 1, 2022 at 2:09 am #2205357DavidStaffCustomer Support
Reading some of Imagifys support topics it looks like there is an option in settings: Use Rewrite Rules for webP generation. And i think that keeps the original
<img>and therefore presumably the classes we add using the above snippet intact. But it cannot be used on sites running a CDN.
If thats not an option then you will need to speak to Imagify and ask them how to add a class to the HTML that their plugin is outputting.May 1, 2022 at 8:08 am #2205717JP
Looks like it’s working now, thank you for your help.May 2, 2022 at 2:21 am #2206178
- You must be logged in to reply to this topic.