woocommerce_get_product_thumbnail

Get the product thumbnail, or the placeholder if not set.

Description

(string) woocommerce_get_product_thumbnail( (string) $size = 'shop_catalog', (int) $deprecated1 = 0, (int) $deprecated2 = 0 ); 

Returns (string)

Parameters (3)

0. $size — Optional. (string) => 'shop_catalog'
(default: shop_catalog)
1. $deprecated1 — Optional. (int)
Deprecated since WooCommerce 2.0 (default: 0)
2. $deprecated2 — Optional. (int)
Deprecated since WooCommerce 2.0 (default: 0)

Usage

  1. if ( !function_exists( 'woocommerce_get_product_thumbnail' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-template-functions.php'; 
  3.  
  4. // (default: 'shop_catalog') 
  5. $size = 'shop_catalog'; 
  6.  
  7. // Deprecated since WooCommerce 2.0 (default: 0) 
  8. $deprecated1 = -1; 
  9.  
  10. // Deprecated since WooCommerce 2.0 (default: 0) 
  11. $deprecated2 = -1; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = woocommerce_get_product_thumbnail($size, $deprecated1, $deprecated2); 
  15.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-template-functions.php  
  1. function woocommerce_get_product_thumbnail( $size = 'shop_catalog', $deprecated1 = 0, $deprecated2 = 0 ) { 
  2. global $post; 
  3. $image_size = apply_filters( 'single_product_archive_thumbnail_size', $size ); 
  4.  
  5. if ( has_post_thumbnail() ) { 
  6. $props = wc_get_product_attachment_props( get_post_thumbnail_id(), $post ); 
  7. return get_the_post_thumbnail( $post->ID, $image_size, array( 
  8. 'title' => $props['title'],  
  9. 'alt' => $props['alt'],  
  10. ) ); 
  11. } elseif ( wc_placeholder_img_src() ) { 
  12. return wc_placeholder_img( $image_size );