Add srcset handling

This commit is contained in:
claudiulodro 2018-09-07 11:36:03 -07:00
parent 847d5b680d
commit 08a76e1eea
2 changed files with 5 additions and 1 deletions

View File

@ -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;
}

View File

@ -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(