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
|
2017-04-10 21:38:16 +00:00
|
|
|
* @version 3.0.2
|
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 );
|
2017-04-17 06:00:26 +00:00
|
|
|
$thumbnail_size = apply_filters( 'woocommerce_product_thumbnails_size', 'full' );
|
2016-10-13 14:25:42 +00:00
|
|
|
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
|
2017-04-17 06:00:26 +00:00
|
|
|
$full_size_image = wp_get_attachment_image_src( $post_thumbnail_id, $thumbnail_size );
|
2017-04-11 11:08:04 +00:00
|
|
|
$image_title = get_post_field( 'post_excerpt', $post_thumbnail_id );
|
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-03-31 14:16:10 +00:00
|
|
|
<div class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $wrapper_classes ) ) ); ?>" data-columns="<?php echo esc_attr( $columns ); ?>" style="opacity: 0; transition: opacity .25s ease-in-out;">
|
2016-10-13 14:25:42 +00:00
|
|
|
<figure class="woocommerce-product-gallery__wrapper">
|
|
|
|
<?php
|
|
|
|
$attributes = array(
|
2017-03-22 12:51:27 +00:00
|
|
|
'title' => $image_title,
|
|
|
|
'data-src' => $full_size_image[0],
|
2017-03-14 10:55:25 +00:00
|
|
|
'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>
|