How do I return only image src from "woocommerce_get_product_thumbnail()"?

Mahade Walid picture Mahade Walid · Nov 23, 2016 · Viewed 14.8k times · Source
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 - https://wordpress.stackexchange.com/questions/9175/how-do-i-get-image-url-only-on-the-post-thumbnail

Is that possible with woocommerce ?

Answer

Gleb Kemarsky picture Gleb Kemarsky · Apr 5, 2017

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 );
}