Hi!
I’m using Cornerstone to build a custom Archive Layout (the front page of my news site). I’m trying to improve LCP and PageSpeed performance by adding attributes like:
fetchpriority="high"
loading="eager"
-
width
,height
decoding="async"
I only want to apply these attributes to the first one or two images on the page , not to all.
The problem is:
When I use the Featured Image element , any attributes I add (via Custom Attributes or filters in functions.php) end up outside the <img>
tag , which means they don’t work.
I tested using the Image (Full Width) element, and in that case, fetchpriority
is correctly placed inside <img>
, but it’s not practical to use this inside a loop or archive layout.
I also tested raw HTML with a manual <img>
tag and that works, but again – not ideal for dynamic post listings.
So my question is:
Is there a way to make the Featured Image element output these attributes inside the <img>
tag, just for the first few images in an archive loop?
Or do you have any recommended workaround?
Thank you so much – I really like working with Cornerstone and just want to improve performance a little more.
Best regards,
Johan Lundgren