Automattic\WooCommerce\Blocks\BlockTypes
FeaturedProduct::get_item_image
Returns the featured product image URL.
Метод класса: FeaturedProduct{}
Хуков нет.
Возвращает
Строку.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_item_image( $product, $size );
- $product(WC_Product) (обязательный)
- Product object.
- $size(строка)
- Image size.
По умолчанию:'full'
Код FeaturedProduct::get_item_image() FeaturedProduct::get item image WC 10.6.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;
}