diff --git a/includes/wc-product-functions.php b/includes/wc-product-functions.php index ed69066bbf7..c9b1119de16 100644 --- a/includes/wc-product-functions.php +++ b/includes/wc-product-functions.php @@ -457,6 +457,10 @@ add_action( 'woocommerce_scheduled_sales', 'wc_scheduled_sales' ); function wc_get_attachment_image_attributes( $attr ) { if ( isset( $attr['src'] ) && strstr( $attr['src'], 'woocommerce_uploads/' ) ) { $attr['src'] = wc_placeholder_img_src(); + + if ( isset( $attr['srcset'] ) ) { + $attr['srcset'] = ''; + } } return $attr; } diff --git a/tests/unit-tests/product/functions.php b/tests/unit-tests/product/functions.php index 7e20800c117..2ed98fed51e 100644 --- a/tests/unit-tests/product/functions.php +++ b/tests/unit-tests/product/functions.php @@ -1013,7 +1013,7 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case { 'src' => 'https://wc.local/wp-content/woocommerce_uploads/my-image.jpg', 'class' => 'attachment-woocommerce_thumbnail size-woocommerce_thumbnail', 'alt' => '', - 'srcset' => '', + 'srcset' => 'https://wc.local/wp-content/woocommerce_uploads/my-image-250x250.jpg 250w, https://wc.local/wp-content/woocommerce_uploads/my-image-350x350 350w', 'sizes' => '(max-width: 250px) 100vw, 250px', ); $expected_attr = array(