CoreBoost v3.3.8
🐛 Fixed - cb-lcp-img Causing Double Height on Desktop / Wrong Size on Mobile
Root Cause
enqueue_optimization_styles() registered .cb-lcp-img CSS via
wp_add_inline_style('wp-block-library', ...). On Elementor sites wp-block-library is
typically never enqueued, so WordPress silently discarded the inline style. Without
position: absolute; inset: 0; width: 100%; height: 100% the injected <img> rendered
as a normal block element — adding its full intrinsic dimensions to the section height
(doubling it on desktop) and appearing as an overlaid, under-sized image on mobile.
Additionally, the parent element needed an explicit position: relative guarantee. Elementor
sections are usually position: relative, but without an enforced rule the absolute positioning
had no reliable containing block.
Changes
output_lcp_img_styles()added (Hero_Optimizer) — newwp_headpriority-1 method that
outputs a<style id="coreboost-cb-lcp">tag directly into the document<head>. Bypasses
wp_enqueue_scriptsentirely, so the CSS is always delivered regardless of which stylesheets
are registered. Only runs whenenable_lcp_foreground_injectionis on and not in admin/preview.- CSS rules:
.cb-lcp { position: relative !important; overflow: hidden; }and
.cb-lcp-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; pointer-events: none; display: block; }. The!importantonposition: relative
prevents any theme or Elementor rule from stripping the containing-block guarantee. define_hooks()— wiredoutput_lcp_img_stylesatwp_headpriority 1.get_foreground_conversion_css()—.cb-lcp-imgblock emptied (styles now owned by
output_lcp_img_styles; legacy.hero-foreground-image/.heroimgrules unchanged).
Files Modified
includes/public/class-hero-optimizer.php—define_hooks(), newoutput_lcp_img_styles(),get_foreground_conversion_css()