Media (LCP optimizer)

mamba_lcp_min_first_image_width
Define the minimum width (in pixels) required for the first image on a page to be treated as a critical LCP candidate.

add_filter('mamba_lcp_min_first_image_width', fn() => 480);

mamba_lcp_push_from_attr
Enable aggressive LCP candidate discovery from markup attributes. Disabled by default.

add_filter('mamba_lcp_push_from_attr', '__return_true', 10, 2);

mamba_lcp_is_critical_image
Mark additional images as critical LCP candidates (theme-level control).

add_filter('mamba_lcp_is_critical_image', function ($isCritical, $attachmentId) {
    return $isCritical || has_term('hero', 'media_tag', $attachmentId);
}, 10, 2);

mamba_lcp_featured_image_size
mamba_lcp_product_main_size
mamba_lcp_product_gallery_size
mamba_lcp_shop_image_size
mamba_lcp_category_image_size

Control which image sizes are used by the LCP optimizer in specific contexts (featured images, product views, galleries, shop grids, categories).

add_filter('mamba_lcp_product_main_size', fn() => 'woocommerce_single');

mamba_lcp_should_output
Globally toggle whether LCP preload tags are emitted.

add_filter('mamba_lcp_should_output', '__return_true');

mamba_lcp_max_image_preloads
Limit the number of image preload tags emitted.

add_filter('mamba_lcp_max_image_preloads', fn() => 2);

mamba_lcp_collect_candidates
Final pass to revise or clean up candidate image URL lists before output.

add_filter('mamba_lcp_collect_candidates', function ($urls, $type) {
    return array_unique(array_filter($urls));
}, 10, 2);

Copyright 2025 - Mamba


Mamba mascot