add-to-cart
2 weeks ago
tabs
1 year ago
back-in-stock-form.php
1 year ago
meta.php
1 year ago
photoswipe.php
1 year ago
price.php
2 years ago
product-attributes.php
2 years ago
product-image.php
3 weeks ago
product-thumbnails.php
3 weeks ago
rating.php
2 years ago
related.php
11 months ago
review-meta.php
2 years ago
review-rating.php
2 years ago
review.php
2 years ago
sale-flash.php
2 years ago
share.php
2 years ago
short-description.php
2 years ago
stock.php
2 years ago
title.php
2 years ago
up-sells.php
1 year ago
product-thumbnails.php
76 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Single Product Thumbnails |
| 4 | * |
| 5 | * This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-thumbnails.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://woocommerce.com/document/template-structure/ |
| 14 | * @package WooCommerce\Templates |
| 15 | * @version 11.1.0 |
| 16 | */ |
| 17 | |
| 18 | use Automattic\WooCommerce\Internal\ProductGallery\ProductMediaGallery; |
| 19 | |
| 20 | defined( 'ABSPATH' ) || exit; |
| 21 | |
| 22 | // 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. |
| 23 | if ( ! function_exists( 'wc_get_gallery_image_html' ) ) { |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | global $product; |
| 28 | |
| 29 | if ( ! $product || ! $product instanceof WC_Product ) { |
| 30 | return ''; |
| 31 | } |
| 32 | |
| 33 | $media_items = ProductMediaGallery::get_product_media_gallery_items_for_display( $product ); |
| 34 | |
| 35 | if ( count( $media_items ) > 1 ) { |
| 36 | foreach ( array_slice( $media_items, 1 ) as $key => $media_item ) { |
| 37 | $attachment_id = isset( $media_item['id'] ) ? absint( $media_item['id'] ) : 0; |
| 38 | |
| 39 | if ( ! $attachment_id ) { |
| 40 | continue; |
| 41 | } |
| 42 | |
| 43 | $is_video = 'video' === ( $media_item['media_type'] ?? '' ); |
| 44 | |
| 45 | if ( $is_video ) { |
| 46 | $html = ProductMediaGallery::get_gallery_video_html( $media_item, false ); |
| 47 | } else { |
| 48 | $html = wc_get_gallery_image_html( $attachment_id, false, $key ); |
| 49 | } |
| 50 | |
| 51 | if ( $is_video ) { |
| 52 | /** |
| 53 | * Filter product video thumbnail HTML string. |
| 54 | * |
| 55 | * @since 11.0.0 |
| 56 | * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. |
| 57 | * |
| 58 | * @param string $html Product video thumbnail HTML string. |
| 59 | * @param int $attachment_id Video attachment ID. |
| 60 | * @param array $media_item Product media gallery item. |
| 61 | */ |
| 62 | echo apply_filters( 'woocommerce_single_product_video_thumbnail_html', $html, $attachment_id, $media_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 63 | } else { |
| 64 | /** |
| 65 | * Filter product image thumbnail HTML string. |
| 66 | * |
| 67 | * @since 1.6.4 |
| 68 | * |
| 69 | * @param string $html Product image thumbnail HTML string. |
| 70 | * @param int $attachment_id Attachment ID. |
| 71 | */ |
| 72 | echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $attachment_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 |