Automattic\WooCommerce\Blocks\BlockTypes
FeaturedProduct::get_item_image()
Returns the featured product image URL.
Method of the class: FeaturedProduct{}
No Hooks.
Return
String
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_item_image( $product, $size );
- $product(\WC_Product) (required)
- Product object.
- $size(string)
- Image size.
Default: 'full'
FeaturedProduct::get_item_image() FeaturedProduct::get item image code WC 9.4.2
protected function get_item_image( $product, $size = 'full' ) { $image = ''; if ( $product->get_image_id() ) { $image = wp_get_attachment_image_url( $product->get_image_id(), $size ); } elseif ( $product->get_parent_id() ) { $parent_product = wc_get_product( $product->get_parent_id() ); if ( $parent_product ) { $image = wp_get_attachment_image_url( $parent_product->get_image_id(), $size ); } } return $image; }