| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- /**
- * Single Product Image
- *
- * This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-image.php.
- *
- * 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.
- *
- * @see https://docs.woocommerce.com/document/template-structure/
- * @author WooThemes
- * @package WooCommerce/Templates
- * @version 3.3.2
- */
- defined( 'ABSPATH' ) || exit;
- global $post, $product;
- $attachment_ids = $product->get_gallery_image_ids();
- $attachment_count = count( $attachment_ids );
- $columns = apply_filters( 'woocommerce_product_thumbnails_columns', 3 );
- $placeholder = has_post_thumbnail() ? 'with-images' : 'without-images';
- $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',
- ) );
- ?>
- <div class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $wrapper_classes ) ) ); ?>" data-columns="<?php echo esc_attr( $columns ); ?>">
- <?php do_action( 'vamtam_woocommerce_before_single_product_images' ) ?>
- <?php
- if ( has_post_thumbnail() || $attachment_count > 0 ) :
- $large_thumbnail_size = apply_filters( 'single_product_large_thumbnail_size', 'shop_single' );
- $small_thumbnail_size = apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' );
- if ( VamtamTemplates::early_cube_load() ) {
- wp_enqueue_script( 'cubeportfolio' );
- }
- wp_enqueue_style( 'cubeportfolio' );
- $slider_options = array(
- 'layoutMode' => 'slider',
- 'drag' => true,
- 'auto' => false,
- 'autoTimeout' => 5000,
- 'autoPauseOnHover' => true,
- 'showNavigation' => true,
- 'showPagination' => false,
- 'rewindNav' => true,
- 'gridAdjustment' => 'responsive',
- 'mediaQueries' => array(
- array(
- 'width' => 1,
- 'cols' => 1,
- ),
- ),
- 'gapHorizontal' => 0,
- 'gapVertical' => 0,
- 'caption' => '',
- 'displayType' => 'default',
- 'plugins' => array(
- 'slider' => array(
- 'pagination' => '#product-gallery-pager-' . intval( $post->ID ),
- 'paginationClass' => 'cbp-pagination-active',
- ),
- ),
- );
- if ( has_post_thumbnail() ) {
- $main_image_id = get_post_thumbnail_id();
- array_unshift( $attachment_ids, $main_image_id );
- }
- ?>
- <div id="product-gallery-<?php echo intval( $post->ID ) ?>" class="vamtam-cubeportfolio cbp cbp-slider-edge" data-options="<?php echo esc_attr( json_encode( $slider_options ) ) ?>">
- <?php foreach ( $attachment_ids as $aid ) : ?>
- <div class="cbp-item">
- <div class="cbp-caption">
- <div class="cbp-caption-defaultWrap">
- <?php
- $full_size_image = wp_get_attachment_image_src( $aid, $large_thumbnail_size );
- $image_title = esc_attr( get_the_title( $aid ) );
- $attributes = array(
- 'class' => 'wp-post-image',
- 'title' => $image_title,
- 'data-caption' => get_post_field( 'post_excerpt', $aid ),
- 'data-src' => $full_size_image[0],
- 'data-large_image' => $full_size_image[0],
- 'data-large_image_width' => $full_size_image[1],
- 'data-large_image_height' => $full_size_image[2],
- );
- if ( has_post_thumbnail() ) {
- $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] ) . '" class="cbp-lightbox">';
- $html .= wp_get_attachment_image( $aid, $large_thumbnail_size, false, $attributes );
- $html .= '</a></div>';
- } else {
- $html = '<div class="woocommerce-product-gallery__image--placeholder">';
- $html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src() ), esc_html__( 'Awaiting product image', 'vamtam-consulting' ) );
- $html .= '</div>';
- }
- echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, get_post_thumbnail_id( $post->ID ) ); // xss ok
- ?>
- </div>
- </div>
- </div>
- <?php endforeach ?>
- </div>
- <?php
- else :
- $html = '<div class="woocommerce-product-gallery__image--placeholder">';
- $html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src() ), esc_html__( 'Awaiting product image', 'vamtam-consulting' ) );
- $html .= '</div>';
- echo $html;
- endif;
- ?>
- <?php if ( $attachment_count > 0 ) : ?>
- <div class="thumbnails" id="product-gallery-pager-<?php echo intval( $post->ID ) ?>"><?php
- $loop = 0;
- foreach ( $attachment_ids as $attachment_id ) {
- $classes = array( 'cbp-pagination-item' );
- if ( 0 === $loop || 0 === $loop % $columns )
- $classes[] = 'first';
- if ( 0 === ( $loop + 1 ) % $columns )
- $classes[] = 'last';
- $image_link = wp_get_attachment_url( $attachment_id );
- if ( $image_link ) {
- $image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ) );
- $image_class = esc_attr( implode( ' ', $classes ) );
- $image_title = esc_attr( get_the_title( $attachment_id ) );
- echo wp_kses_post( apply_filters( 'vamtam_woocommerce_single_product_image_thumbnail_html', sprintf( '<div class="%s" title="%s">%s</div>', $image_class, $image_title, $image ), $attachment_id, $post->ID, $image_class ) );
- $loop++;
- }
- }
- ?></div>
- <?php endif ?>
- <?php do_action( 'vamtam_woocommerce_after_single_product_images' ) ?>
- </div>
|