• Resolved Hirak Kalita

    (@rieiirir)


    How to add fetchpriority=”high” to the vpi image to improve LCP score for Core Web Vitals. Please give a feature to add fetchpriority=”high” to the VPI image to load ASAP. Alternately, give me the code to check if the image a VPI. Then I can add fetchpriority=”high” using function.php

    Official docs: https://web.dev/priority-hints/

    Core web vital is a ranking factor and LCP score a is part one of them.

    Report number: CHQGKNMO Report date: 03/25/2023 07:11:52

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Hirak Kalita

    (@rieiirir)

    I got a function to set the hint for viewport featured image only one time. It will not repeat if page contains multiple featured image as my target is for VPI.

    add_filter(‘wp_lazy_loading_enabled’, ‘__return_false’);

    function add_featured_image_attribute( $attr, $attachment, $size ) { // Check if the current page is a single post page

    if ( is_single() ) { global $post; static $count = 0;

    // Increment the count of featured images displayed $count++;

    // Add the attribute only to the first featured image if ( $count === 1 && has_post_thumbnail( $post->ID ) ) { $attr[‘fetchpriority’] = ‘high’; } } return $attr;}add_filter( ‘wp_get_attachment_image_attributes’, ‘add_featured_image_attribute’, 10, 3 );

    Please give a feature to add fetchpriority=”high” to the VPI image to load ASAP.

    This feature was suggested to LiteSpeed Slack several months ago.

    FYI: I already use fetchpriority=”high” (non WP page), but there isn’t much improvement, so don’t expect a turbo. Especially if you use other preload functions. However, it is only supported by Chrome browser.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add fetchpriority=”high” to the VPI image for improve LCP’ is closed to new replies.