WordPress 5.5 added loading="lazy" to every image by default, which sounds like a Core Web Vitals win — and is, except for the hero image. When the largest contentful paint candidate gets loading="lazy", the browser delays the request until the layout settles, and LCP regresses by 200-800 ms. WordPress 5.9 added logic to skip the attribute on the first image, but the heuristic is fragile and most production sites get bitten at least once.
What’s happening
WordPress’s wp_filter_content_tags() (called from the_content and friends) walks the rendered HTML, finds <img> tags, and injects loading="lazy" when the attribute is absent. Since 5.9, it also tracks an “is the first image” counter and skips the lazy attribute on that first image, on the theory that the first image is the LCP candidate. The theory works on simple layouts and fails on three common patterns: blocks rendered above the title (cover blocks), images inside template parts (the site header logo counts as the first image), and images injected by shortcodes that bypass the filter.
The result: on themes with a logo in the header, the logo gets the “no lazy” treatment and the hero image — the actual LCP — gets loading="lazy". LCP regresses, the editorial team has no idea why, and the Lighthouse report flags it.
How to verify
curl -s https://example.com/article-slug/ | grep -oE '<img[^>]+loading="[^"]+"[^>]*>' | head -5
curl -s https://example.com/article-slug/ | grep -oE '<img[^>]+>' | head -10
wp eval 'echo get_option("wp_omit_loading_attr_threshold") . PHP_EOL;'
npx lighthouse https://example.com/article-slug/ --only-categories=performance --quiet
Open the page in Chrome, DevTools > Performance > Insights tab. The “LCP” entry shows the LCP element. If it has loading="lazy", the heuristic failed for you.
The fix
- Use the
fetchpriority="high"attribute on the hero image. Since WordPress 6.3, core setsfetchpriority="high"on the first content image. Confirm it lands on the right image; if the heuristic picks the wrong one, override with a filter. - Filter
wp_omit_loading_attr_thresholdto control the first-image skip. Returning0disables the skip entirely (every image gets lazy). Returning2skips the first two images (useful when the logo counts as image one). - Override per-template. For archive pages and homepages, the LCP is usually a specific block or featured image. Use the
wp_get_loading_optimization_attributesfilter to setfetchpriority="high"on that specific image andloading="eager"to prevent lazy. - Strip lazy from images injected by plugins. Page builders (Elementor, Beaver Builder) sometimes add their own lazy-load on top of core’s. Two lazy attributes is one too many — pick one.
- Test with WebPageTest, not just Lighthouse. Lighthouse runs locally on a fast network. WebPageTest runs from a real mobile profile and catches LCP regressions Lighthouse misses. For sites under Enterprise WordPress management, Core Web Vitals checks run on a synthetic schedule and break the build when LCP regresses past threshold.
Stack Harbor’s Enterprise WordPress operating model includes Core Web Vitals monitoring with synthetic checks on the key templates, not just the homepage. When LCP keeps regressing on releases, start the conversation.