@morvy judging from what you tell me, I agree that the issue happen with VPI ON.
Can you make sure the page html is correct and if you have escaped html, please tell me.
Thread Starter
morvy
(@morvy)
Hi,
Yes, the page HTML is correct. It does contain escaped HTML, but only inside a JavaScript string in an inline script block. WooCommerce core outputs it in woocommerce_variable_add_to_cart() (includes/wc-template-functions.php), using wp_add_inline_script() + wp_json_encode(). This is the clean output on website with VPI off:
<script id="wc-add-to-cart-variation-js-before">
(window.wc_variation_gallery_defaults = window.wc_variation_gallery_defaults || {})[3193] = "<div class=\"woocommerce-product-gallery\" ...><img width=\"600\" height=\"600\" src=\"https:\/\/example.org\/wp-content\/uploads\/...-600x600.png\" ... decoding=\"async\" ...>...";
</script>
This is valid JS and appears on every variable product page on any WooCommerce site with a recent version.
With VPI on, LiteSpeed treats the img tag inside that JS string as a real tag. Media::_parse_img_for_preload() runs this on the full page, script contents included:
preg_match_all('#]+)/?>#isU', $content, $matches, PREG_SET_ORDER);
Same product on “identical” website with VPI on. The tag inside the JS string becomes:
<img width="\"600\"" height="\"600\"" src="\/\/example.org\/wp-content\/uploads\/...-600x600.png\"" ... decoding="sync" srcset="\"https:\/\/..." 600w,="" https:\="" \="" ...>
and this is added to the page head:
<link rel="preload" fetchpriority="high" as="image" href="//example.org/wp-content/uploads/...-600x600.png"">
So it’s more than just the trailing quotation mark as you can see, but it’s the first thing that started polluting my access logs after I enabled the feature.
@morvy can you please share a report ID with me?
The report can be sent from https://docs.litespeedtech.com/lscache/lscwp/toolbox/#report-tab and share the ID(just the ID generated).
Thank you
Thread Starter
morvy
(@morvy)
Hello,
report ID from site where I disabled VPI : BFUAAAOQ
As soon as I disabled it, everything went to normal, no broken image urls in past 24 hours
@morvy please test the latest dev code and tell me if this fixes your issue.
This can be done from LSCWP => Toolbox => Beta Test => write dev in the input and click on Update
Clear cache and test if this fixes your issue.
Then, please return to latest code from WordPress. You can do this from Beta Test too.
Thank you
Thread Starter
morvy
(@morvy)
Hello,
I’ll be checking access logs for a while, but source code looks clean now. Will post update in 2-3 days.
Thanks!