Merge pull request #9685 from tiagonoronha/9624-variation-image-srcset-sizes
[2.4] Adds support for srcset and sizes attributes in variation images. @claudiosmweb
This commit is contained in:
commit
557ce96842
|
@ -451,12 +451,16 @@
|
|||
$product_img.wc_set_variation_attr( 'src', variation.image_src );
|
||||
$product_img.wc_set_variation_attr( 'title', variation.image_title );
|
||||
$product_img.wc_set_variation_attr( 'alt', variation.image_title );
|
||||
$product_img.wc_set_variation_attr( 'srcset', variation.image_srcset );
|
||||
$product_img.wc_set_variation_attr( 'sizes', variation.image_sizes );
|
||||
$product_link.wc_set_variation_attr( 'href', variation.image_link );
|
||||
$product_link.wc_set_variation_attr( 'title', variation.image_caption );
|
||||
} else {
|
||||
$product_img.wc_reset_variation_attr( 'src' );
|
||||
$product_img.wc_reset_variation_attr( 'title' );
|
||||
$product_img.wc_reset_variation_attr( 'alt' );
|
||||
$product_img.wc_reset_variation_attr( 'srcset' );
|
||||
$product_img.wc_reset_variation_attr( 'sizes' );
|
||||
$product_link.wc_reset_variation_attr( 'href' );
|
||||
$product_link.wc_reset_variation_attr( 'title' );
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -563,6 +563,8 @@ class WC_Product_Variable extends WC_Product {
|
|||
$image_link = $full_attachment ? current( $full_attachment ) : '';
|
||||
$image_title = get_the_title( $attachment_id );
|
||||
$image_alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
|
||||
$image_srcset = wp_get_attachment_image_srcset( $attachment_id, 'shop_single' );
|
||||
$image_sizes = wp_get_attachment_image_sizes( $attachment_id, 'shop_single' );
|
||||
} else {
|
||||
$image = $image_link = $image_title = $image_alt = '';
|
||||
}
|
||||
|
@ -583,6 +585,8 @@ class WC_Product_Variable extends WC_Product {
|
|||
'image_link' => $image_link,
|
||||
'image_title' => $image_title,
|
||||
'image_alt' => $image_alt,
|
||||
'image_srcset' => $image_srcset,
|
||||
'image_sizes' => $image_sizes,
|
||||
'price_html' => apply_filters( 'woocommerce_show_variation_price', $variation->get_price() === "" || $this->get_variation_price( 'min' ) !== $this->get_variation_price( 'max' ), $this, $variation ) ? '<span class="price">' . $variation->get_price_html() . '</span>' : '',
|
||||
'availability_html' => $availability_html,
|
||||
'sku' => $variation->get_sku(),
|
||||
|
|
Loading…
Reference in New Issue