Hi @wesleylancel,
Apologies for the late reply, we’ve been trying to replicate the issue at our end with no great success. It looks like it’s quite a peculiar issue that’s not easy to get replicated.
We dug a little further on that, and my main suspects fall into a timing problem: the WooCommerce script could be running before the Jetpack script, hence the WooCommerce script doesn’t see an image yet.
There are a couple of options you can try out – I’ll list the easier and then the more complicated one.
– try using the Regenerate Thumbnails plugin: it worked beautifully in some cases.
– if that ^^ won’t help, then you can try adding a filter in the function.php
file:
add_filter( 'wp_get_attachment_image_attributes',function ($attributes, $attachment, $size){ if ( $attachment ) { $src = image_downsize( $attachment->ID, $size ); if ( $src ) { $attributes['srcwidth'] = $src[1]; $attributes['srcheight'] = $src[2]; } } return $attributes; },10, 3 );
add_filter( 'jetpack_lazy_images_new_attributes',function ($attributes){ if ( !empty( $attributes['srcwidth'] ) && !empty( $attributes['srcheight'] )){ $attributes['srcset'] = "data:image/svg+xml,%3Csvg xmlns='https://www.w3.org/2000/svg' viewBox='0 0 ".$attributes['srcwidth']." ".$attributes['srcheight']." '%3E%3C/svg%3E"; } return $attributes; } );
This has been documented in this GitHub issue, so I trust it could work in your site too ??
You can use a plugin such as Code Snippets to add the filter above to your site:
https://www.ads-software.com/plugins/code-snippets/
Hope that’s all clear. Let us know how it goes!