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 /
2020-08-05 16:36:24 +00:00
* @ package WooCommerce\Templates
2020-10-26 13:26:29 +00:00
* @ version 3.5 . 1
2011-12-11 01:08:33 +00:00
*/
2018-02-12 17:49:53 +00:00
defined ( 'ABSPATH' ) || exit ;
2018-02-13 19:18:13 +00:00
// 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.
if ( ! function_exists ( 'wc_get_gallery_image_html' ) ) {
return ;
}
2018-02-12 17:49:53 +00:00
global $product ;
2012-10-15 10:57:58 +00:00
2016-10-13 14:25:42 +00:00
$columns = apply_filters ( 'woocommerce_product_thumbnails_columns' , 4 );
2020-10-26 13:26:29 +00:00
$post_thumbnail_id = $product -> get_image_id ();
2019-12-20 18:25:23 +00:00
$wrapper_classes = apply_filters (
'woocommerce_single_product_image_gallery_classes' ,
array (
'woocommerce-product-gallery' ,
2021-01-25 11:42:27 +00:00
'woocommerce-product-gallery--' . ( $post_thumbnail_id ? 'with-images' : 'without-images' ),
2019-12-20 18:25:23 +00:00
'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
2021-01-25 11:42:27 +00:00
if ( $post_thumbnail_id ) {
2018-10-18 12:11:26 +00:00
$html = wc_get_gallery_image_html ( $post_thumbnail_id , true );
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">' ;
2018-09-24 19:45:55 +00:00
$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' ) );
2017-03-14 10:42:21 +00:00
$html .= '</div>' ;
2013-03-10 13:07:36 +00:00
}
2018-10-18 12:11:26 +00:00
echo apply_filters ( 'woocommerce_single_product_image_thumbnail_html' , $html , $post_thumbnail_id ); // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped
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 >