add-to-cart
9 years ago
tabs
9 years ago
meta.php
9 years ago
photoswipe.php
9 years ago
price.php
9 years ago
product-attributes.php
9 years ago
product-image.php
9 years ago
product-thumbnails.php
9 years ago
rating.php
9 years ago
related.php
9 years ago
review-meta.php
9 years ago
review-rating.php
9 years ago
review.php
9 years ago
sale-flash.php
9 years ago
share.php
9 years ago
short-description.php
9 years ago
stock.php
9 years ago
title.php
9 years ago
up-sells.php
9 years ago
product-image.php
64 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Single Product Image |
| 4 | * |
| 5 | * This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-image.php. |
| 6 | * |
| 7 | * HOWEVER, on occasion WooCommerce will need to update template files and you |
| 8 | * (the theme developer) will need to copy the new files to your theme to |
| 9 | * maintain compatibility. We try to do this as little as possible, but it does |
| 10 | * happen. When this occurs the version of the template file will be bumped and |
| 11 | * the readme will list any important changes. |
| 12 | * |
| 13 | * @see https://docs.woocommerce.com/document/template-structure/ |
| 14 | * @author WooThemes |
| 15 | * @package WooCommerce/Templates |
| 16 | * @version 3.0.0 |
| 17 | */ |
| 18 | |
| 19 | if ( ! defined( 'ABSPATH' ) ) { |
| 20 | exit; |
| 21 | } |
| 22 | |
| 23 | global $post, $product; |
| 24 | $columns = apply_filters( 'woocommerce_product_thumbnails_columns', 4 ); |
| 25 | $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); |
| 26 | $full_size_image = wp_get_attachment_image_src( $post_thumbnail_id, 'full' ); |
| 27 | $thumbnail_post = get_post( $post_thumbnail_id ); |
| 28 | $image_title = $thumbnail_post->post_content; |
| 29 | $placeholder = has_post_thumbnail() ? 'with-images' : 'without-images'; |
| 30 | $wrapper_classes = apply_filters( 'woocommerce_single_product_image_gallery_classes', array( |
| 31 | 'woocommerce-product-gallery', |
| 32 | 'woocommerce-product-gallery--' . $placeholder, |
| 33 | 'woocommerce-product-gallery--columns-' . absint( $columns ), |
| 34 | 'images', |
| 35 | ) ); |
| 36 | ?> |
| 37 | <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;"> |
| 38 | <figure class="woocommerce-product-gallery__wrapper"> |
| 39 | <?php |
| 40 | $attributes = array( |
| 41 | 'title' => $image_title, |
| 42 | 'data-src' => $full_size_image[0], |
| 43 | 'data-large_image' => $full_size_image[0], |
| 44 | 'data-large_image_width' => $full_size_image[1], |
| 45 | 'data-large_image_height' => $full_size_image[2], |
| 46 | ); |
| 47 | |
| 48 | if ( has_post_thumbnail() ) { |
| 49 | $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] ) . '">'; |
| 50 | $html .= get_the_post_thumbnail( $post->ID, 'shop_single', $attributes ); |
| 51 | $html .= '</a></div>'; |
| 52 | } else { |
| 53 | $html = '<div class="woocommerce-product-gallery__image--placeholder">'; |
| 54 | $html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src() ), esc_html__( 'Awaiting product image', 'woocommerce' ) ); |
| 55 | $html .= '</div>'; |
| 56 | } |
| 57 | |
| 58 | echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, get_post_thumbnail_id( $post->ID ) ); |
| 59 | |
| 60 | do_action( 'woocommerce_product_thumbnails' ); |
| 61 | ?> |
| 62 | </figure> |
| 63 | </div> |
| 64 |