move image id logic to woocommerce_show_product_*
This commit is contained in:
parent
41d53a9880
commit
84d6d6c525
|
@ -1473,7 +1473,16 @@ if ( ! function_exists( 'woocommerce_show_product_images' ) ) {
|
|||
* Output the product image before the single product summary.
|
||||
*/
|
||||
function woocommerce_show_product_images() {
|
||||
wc_get_template( 'single-product/product-image.php' );
|
||||
global $product;
|
||||
$post_thumbnail_id = $product->get_image_id();
|
||||
if ( ! $post_thumbnail_id ) {
|
||||
$gallery_image_ids = $product->get_gallery_image_ids();
|
||||
if ( ! empty( $gallery_image_ids ) ) {
|
||||
$post_thumbnail_id = array_shift( $gallery_image_ids );
|
||||
}
|
||||
}
|
||||
$args = compact( 'post_thumbnail_id', 'gallery_image_ids' );
|
||||
wc_get_template( 'single-product/product-image.php', $args );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'woocommerce_show_product_thumbnails' ) ) {
|
||||
|
@ -1482,7 +1491,13 @@ if ( ! function_exists( 'woocommerce_show_product_thumbnails' ) ) {
|
|||
* Output the product thumbnails.
|
||||
*/
|
||||
function woocommerce_show_product_thumbnails() {
|
||||
wc_get_template( 'single-product/product-thumbnails.php' );
|
||||
global $product;
|
||||
$attachment_ids = $product->get_gallery_image_ids();
|
||||
|
||||
if ( $attachment_ids && ! $product->get_image_id() ) {
|
||||
array_shift( $attachment_ids );
|
||||
}
|
||||
wc_get_template( 'single-product/product-thumbnails.php', array( 'attachment_ids' => $attachment_ids ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,13 +25,6 @@ if ( ! function_exists( 'wc_get_gallery_image_html' ) ) {
|
|||
global $product;
|
||||
|
||||
$columns = apply_filters( 'woocommerce_product_thumbnails_columns', 4 );
|
||||
$post_thumbnail_id = $product->get_image_id();
|
||||
if ( ! $post_thumbnail_id ) {
|
||||
$gallery_image_ids = $product->get_gallery_image_ids();
|
||||
if ( ! empty( $gallery_image_ids ) ) {
|
||||
$post_thumbnail_id = array_shift( $gallery_image_ids );
|
||||
}
|
||||
}
|
||||
$wrapper_classes = apply_filters(
|
||||
'woocommerce_single_product_image_gallery_classes',
|
||||
array(
|
||||
|
|
|
@ -24,12 +24,7 @@ if ( ! function_exists( 'wc_get_gallery_image_html' ) ) {
|
|||
|
||||
global $product;
|
||||
|
||||
$attachment_ids = $product->get_gallery_image_ids();
|
||||
|
||||
if ( $attachment_ids ) {
|
||||
if ( ! $product->get_image_id() ) {
|
||||
array_shift( $attachment_ids );
|
||||
}
|
||||
foreach ( $attachment_ids as $attachment_id ) {
|
||||
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', wc_get_gallery_image_html( $attachment_id ), $attachment_id ); // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue