Home Forums WoodMart support forum WoodMart LCP setting is marked with the original JPG URL

WoodMart LCP setting is marked with the original JPG URL

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #694929

    chienfeiliu
    Participant

    I use litspeed cache and QUIC CDN, LiteSpeed Cache (LSC) has enabled image optimization/WebP, I set woodmart Preload LCP Image on, but the WoodMart LCP setting is marked with the original JPG URL, The LCP metric still captures JPG, not the CDN/optimized WebP version。
    When I run Pagespeed tests, images consistently fail to apply fetchpriority=high, and Webp image URLs persistently delay loading.
    What should I do?
    tanks

    #695038

    chienfeiliu
    Participant

    I enabled the WoodMart LCP option and disabled the image lazy loading feature, but PageSpeed still shows that this LCP image has a Resource load delay of 2,530 ms and that “fetchpriority=high should be applied.”
    It also says the request is discoverable in the initial document. Why is this happening?

    Attachments:
    You must be logged in to view attached files.
    #695116

    Artem Temos
    Keymaster

    Hello,

    Please provide us with your admin access so we can log in and check this on your end.

    Thank you in advance.

    #695118

    chienfeiliu
    Participant

    ok

    #695169

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to fix this

    add_filter('woodmart_get_webp_image_srcset', function ($url, $image_id) {
    	if ( $url ) {
    		$image_srcset_array = explode( ',', $url );
    
    		foreach ( $image_srcset_array as $key => $srcset_line ) {
    			$srcset_line_array = explode( ' ', trim( $srcset_line ) );
    
    			if ( false === strpos( $srcset_line_array[0], '.webp' ) && woodmart_attachment_url_to_path( $srcset_line_array[0] . '.webp' ) ) {
    				$srcset_line_array[0] = $srcset_line_array[0] . '.webp';
    			}
    
    			$image_srcset_array[ $key ] = implode( ' ', $srcset_line_array );
    		}
    
    		$url = implode( ',', $image_srcset_array );
    	}
    
    	return $url;
    }, 10, 2);
    
    add_action('wp_head', function () {
    	add_action('woodmart_get_image_src', 'wd_add_wepb_for_preload', 10);
    }, 1);
    
    add_action('wd_head', function () {
    	remove_action('woodmart_get_image_src', 'wd_add_wepb_for_preload');
    }, 10000);
    
    function wd_add_wepb_for_preload( $image_src ) {
    	if ( false === strpos( $image_src, '.webp' ) && woodmart_attachment_url_to_path( $image_src . '.webp' ) ) {
    		$image_src = $image_src . '.webp';
    	}
    
    	return $image_src;
    }

    Kind Regards

    #695185

    chienfeiliu
    Participant

    I’ve added the code and fixed part of the issue, but the images still have loading delays.

    Attachments:
    You must be logged in to view attached files.
    #695297

    Artem Temos
    Keymaster

    We just analyzed your website, but don’t see any errors related to the LCP. Check the screenshot https://gyazo.com/a58c38adb85382252000cdb8926c517a

Viewing 7 posts - 1 through 7 (of 7 total)