yit_get_product_image_id

Get the attach image id.

Description

yit_get_product_image_id( (WC_Product) $product, (string) $context = 'view' ); 

Parameters (2)

0. $product (WC_Product)
The product.
1. $context — Optional. (string) => 'view'
( view/edit )

Usage

  1. if ( !function_exists( 'yit_get_product_image_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yith-woocommerce-wishlist/plugin-fw/yit-woocommerce-compatibility.php'; 
  3.  
  4. // The product. 
  5. $product = null; 
  6.  
  7. // ( view/edit ) 
  8. $context = 'view'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = yit_get_product_image_id($product, $context); 
  12.  

Defined (1)

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

/plugin-fw/yit-woocommerce-compatibility.php  
  1. function yit_get_product_image_id( $product, $context = 'view' ) { 
  2.  
  3. if ( version_compare( WC()->version, '2.7.0', '>=' ) ) { 
  4.  
  5. $image_id = $product->get_image_id( $context ); 
  6. } else { 
  7.  
  8. $image_id = $product->get_image_id(); 
  9.  
  10. return $image_id;