add-to-cart
5 years ago
tabs
5 years ago
meta.php
5 years ago
photoswipe.php
5 years ago
price.php
5 years ago
product-attributes.php
5 years ago
product-image.php
5 years ago
product-thumbnails.php
5 years ago
rating.php
5 years ago
related.php
5 years ago
review-meta.php
5 years ago
review-rating.php
5 years ago
review.php
5 years ago
sale-flash.php
5 years ago
share.php
5 years ago
short-description.php
5 years ago
stock.php
5 years ago
title.php
5 years ago
up-sells.php
5 years ago
product-image.php
56 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 | * @package WooCommerce\Templates |
| 15 | * @version 3.5.1 |
| 16 | */ |
| 17 | |
| 18 | defined( 'ABSPATH' ) || exit; |
| 19 | |
| 20 | // Note: `wc_get_gallery_image_html` was added in WC 3.3.2 and did not exist prior. This check protects against theme overrides being used on older versions of WC. |
| 21 | if ( ! function_exists( 'wc_get_gallery_image_html' ) ) { |
| 22 | return; |
| 23 | } |
| 24 | |
| 25 | global $product; |
| 26 | |
| 27 | $columns = apply_filters( 'woocommerce_product_thumbnails_columns', 4 ); |
| 28 | $post_thumbnail_id = $product->get_image_id(); |
| 29 | $wrapper_classes = apply_filters( |
| 30 | 'woocommerce_single_product_image_gallery_classes', |
| 31 | array( |
| 32 | 'woocommerce-product-gallery', |
| 33 | 'woocommerce-product-gallery--' . ( $post_thumbnail_id ? 'with-images' : 'without-images' ), |
| 34 | 'woocommerce-product-gallery--columns-' . absint( $columns ), |
| 35 | 'images', |
| 36 | ) |
| 37 | ); |
| 38 | ?> |
| 39 | <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;"> |
| 40 | <figure class="woocommerce-product-gallery__wrapper"> |
| 41 | <?php |
| 42 | if ( $post_thumbnail_id ) { |
| 43 | $html = wc_get_gallery_image_html( $post_thumbnail_id, true ); |
| 44 | } else { |
| 45 | $html = '<div class="woocommerce-product-gallery__image--placeholder">'; |
| 46 | $html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ), esc_html__( 'Awaiting product image', 'woocommerce' ) ); |
| 47 | $html .= '</div>'; |
| 48 | } |
| 49 | |
| 50 | echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $post_thumbnail_id ); // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped |
| 51 | |
| 52 | do_action( 'woocommerce_product_thumbnails' ); |
| 53 | ?> |
| 54 | </figure> |
| 55 | </div> |
| 56 |