Z
Z
zuraavl2018-11-09 20:52:19
WordPress
zuraavl, 2018-11-09 20:52:19

How to show all product photos in its thumbnail?

I need to display in the product thumbnail all the images that are added to the product. Main image and gallery images. Display them in the background image

<div class="pic-bg" style="background-image: url( %%% );"></div>

I found such a code that will allow you to somehow change the output of images in a thumbnail. I add it to function.php
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);


if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) {
    function woocommerce_template_loop_product_thumbnail() {
        echo woocommerce_get_product_thumbnail();
    } 
}
if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) {   
    function woocommerce_get_product_thumbnail( $size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0  ) {
        global $post, $woocommerce;
        $output = '<div class="imagewrapper">';

        if ( has_post_thumbnail() ) {               
            $output .= get_the_post_thumbnail( $post->ID, $size );  
        }                       
        $output .= '</div>';
        return $output;
    }
}

I can not figure out what to insert there to display what you need. I don't know php

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question