echo woocommerce_get_product_thumbnail();
That output the whole image tag. How can I get only the image source?
Same problems solution with just WordPress: How do I get image url only on the_post_thumbnail
Is that possible with WooCommerce?
Try to write your own code based on the function woocommerce_get_product_thumbnail()
from wp-content/plugins/woocommerce/includes/wc-template-functions.php
. For example:
function my_get_the_product_thumbnail_url( $size = 'shop_catalog' ) {
global $post;
$image_size = apply_filters( 'single_product_archive_thumbnail_size', $size );
return get_the_post_thumbnail_url( $post->ID, $image_size );
}
You can get the thumbnail of any post as such:
$thumbnail = get_the_post_thumbnail_url($post->ID);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With