diff --git a/templates/single-product/product-thumbnails.php b/templates/single-product/product-thumbnails.php index da0799c3a92..d83ef34e109 100644 --- a/templates/single-product/product-thumbnails.php +++ b/templates/single-product/product-thumbnails.php @@ -13,11 +13,11 @@ * @see https://docs.woocommerce.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates - * @version 2.3.0 + * @version 2.6.3 */ if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly + exit; } global $post, $product, $woocommerce; @@ -34,28 +34,35 @@ if ( $attachment_ids ) { $classes = array( 'zoom' ); - if ( $loop === 0 || $loop % $columns === 0 ) + if ( $loop === 0 || $loop % $columns === 0 ) { $classes[] = 'first'; + } - if ( ( $loop + 1 ) % $columns === 0 ) + if ( ( $loop + 1 ) % $columns === 0 ) { $classes[] = 'last'; + } - $image_link = wp_get_attachment_url( $attachment_id ); - - if ( ! $image_link ) + if ( ! $image_link = wp_get_attachment_url( $attachment_id ) ) { continue; + } - $image_title = esc_attr( get_the_title( $attachment_id ) ); - $image_caption = esc_attr( get_post_field( 'post_excerpt', $attachment_id ) ); + $props = wc_get_product_attachment_props( $attachment_id, $post ); + $image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ), 0, $props ); + $image_class = implode( ' ', $classes ); - $image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ), 0, $attr = array( - 'title' => $image_title, - 'alt' => $image_title - ) ); - - $image_class = esc_attr( implode( ' ', $classes ) ); - - echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', sprintf( '%s', $image_link, $image_class, $image_caption, $image ), $attachment_id, $post->ID, $image_class ); + echo apply_filters( + 'woocommerce_single_product_image_thumbnail_html', + sprintf( + '%s', + $image_link, + esc_attr( $image_class ), + esc_attr( $props['caption'] ), + $image + ), + $attachment_id, + $post->ID, + esc_attr( $image_class ) + ); $loop++; }