Update product-image.php
Fix to correctly calculate $attachment_count
This commit is contained in:
parent
d5cf03a636
commit
769fada460
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
global $post, $woocommerce;
|
global $post, $woocommerce, $product;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="images">
|
<div class="images">
|
||||||
|
@ -20,9 +20,9 @@ global $post, $woocommerce;
|
||||||
$image = get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
|
$image = get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
|
||||||
$image_title = esc_attr( get_the_title( get_post_thumbnail_id() ) );
|
$image_title = esc_attr( get_the_title( get_post_thumbnail_id() ) );
|
||||||
$image_link = wp_get_attachment_url( get_post_thumbnail_id() );
|
$image_link = wp_get_attachment_url( get_post_thumbnail_id() );
|
||||||
$attachment_count = count( get_children( array( 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_type' => 'attachment' ) ) );
|
$attachment_count = count( $product->get_gallery_attachment_ids() );
|
||||||
|
|
||||||
if ( $attachment_count != 1 ) {
|
if ( $attachment_count > 0 ) {
|
||||||
$gallery = '[product-gallery]';
|
$gallery = '[product-gallery]';
|
||||||
} else {
|
} else {
|
||||||
$gallery = '';
|
$gallery = '';
|
||||||
|
@ -39,4 +39,4 @@ global $post, $woocommerce;
|
||||||
|
|
||||||
<?php do_action( 'woocommerce_product_thumbnails' ); ?>
|
<?php do_action( 'woocommerce_product_thumbnails' ); ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue