2011-12-11 01:08:33 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-11-03 13:53:50 +00:00
|
|
|
* Single Product Image
|
2012-08-14 18:05:45 +00:00
|
|
|
*
|
2015-11-03 13:31:20 +00:00
|
|
|
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-image.php.
|
2015-10-01 14:07:20 +00:00
|
|
|
*
|
2016-02-12 11:28:41 +00:00
|
|
|
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
|
|
|
* (the theme developer) will need to copy the new files to your theme to
|
|
|
|
* maintain compatibility. We try to do this as little as possible, but it does
|
|
|
|
* happen. When this occurs the version of the template file will be bumped and
|
|
|
|
* the readme will list any important changes.
|
2015-10-01 14:07:20 +00:00
|
|
|
*
|
2016-10-13 19:58:20 +00:00
|
|
|
* @see https://docs.woocommerce.com/document/template-structure/
|
|
|
|
* @author WooThemes
|
|
|
|
* @package WooCommerce/Templates
|
|
|
|
* @version 2.7.0
|
2011-12-11 01:08:33 +00:00
|
|
|
*/
|
|
|
|
|
2014-09-22 16:37:57 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
2016-07-19 18:06:44 +00:00
|
|
|
exit;
|
2014-09-22 16:37:57 +00:00
|
|
|
}
|
2012-10-15 10:57:58 +00:00
|
|
|
|
2016-05-03 15:41:51 +00:00
|
|
|
global $post, $product;
|
2016-10-13 14:25:42 +00:00
|
|
|
$columns = apply_filters( 'woocommerce_product_thumbnails_columns', 4 );
|
|
|
|
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
|
|
|
|
$full_size_image = wp_get_attachment_image_src( $post_thumbnail_id, 'full' );
|
|
|
|
$thumbnail_post = get_post( $post_thumbnail_id );
|
|
|
|
$image_title = $thumbnail_post->post_content;
|
2017-01-16 14:17:03 +00:00
|
|
|
$placeholder = has_post_thumbnail() ? 'with-images' : 'without-images';
|
2017-01-27 16:52:23 +00:00
|
|
|
$wrapper_classes = apply_filters( 'woocommerce_single_product_image_gallery_classes', array(
|
|
|
|
'woocommerce-product-gallery',
|
|
|
|
'woocommerce-product-gallery--' . $placeholder,
|
|
|
|
'woocommerce-product-gallery--columns-' . absint( $columns ),
|
|
|
|
'images',
|
|
|
|
) );
|
2011-12-11 01:08:33 +00:00
|
|
|
?>
|
2017-01-27 16:52:23 +00:00
|
|
|
<div class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $wrapper_classes ) ) ); ?>" data-columns="<?php echo esc_attr( $columns ); ?>">
|
2016-10-13 14:25:42 +00:00
|
|
|
<figure class="woocommerce-product-gallery__wrapper">
|
|
|
|
<?php
|
|
|
|
$attributes = array(
|
2017-03-14 10:55:25 +00:00
|
|
|
'title' => $image_title,
|
|
|
|
'data-large_image' => $full_size_image[0],
|
|
|
|
'data-large_image_width' => $full_size_image[1],
|
|
|
|
'data-large_image_height' => $full_size_image[2],
|
2016-10-13 14:25:42 +00:00
|
|
|
);
|
2017-01-26 14:50:40 +00:00
|
|
|
|
2013-03-10 13:07:36 +00:00
|
|
|
if ( has_post_thumbnail() ) {
|
2017-03-14 10:42:21 +00:00
|
|
|
$html = '<div data-thumb="' . get_the_post_thumbnail_url( $post->ID, 'shop_thumbnail' ) . '" class="woocommerce-product-gallery__image"><a href="' . esc_url( $full_size_image[0] ) . '">';
|
2017-01-27 15:35:20 +00:00
|
|
|
$html .= get_the_post_thumbnail( $post->ID, 'shop_single', $attributes );
|
2017-03-14 10:42:21 +00:00
|
|
|
$html .= '</a></div>';
|
2013-03-10 13:07:36 +00:00
|
|
|
} else {
|
2017-03-14 10:42:21 +00:00
|
|
|
$html = '<div class="woocommerce-product-gallery__image--placeholder">';
|
2017-01-27 15:35:20 +00:00
|
|
|
$html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src() ), esc_html__( 'Awaiting product image', 'woocommerce' ) );
|
2017-03-14 10:42:21 +00:00
|
|
|
$html .= '</div>';
|
2013-03-10 13:07:36 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:35:20 +00:00
|
|
|
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, get_post_thumbnail_id( $post->ID ) );
|
2017-01-26 14:50:40 +00:00
|
|
|
|
2016-05-03 15:41:51 +00:00
|
|
|
do_action( 'woocommerce_product_thumbnails' );
|
2016-10-13 14:25:42 +00:00
|
|
|
?>
|
|
|
|
</figure>
|
2013-04-26 14:42:41 +00:00
|
|
|
</div>
|