Automattic\WooCommerce\StoreApi\Schemas\V1
ShopperListItemSchema::get_image_html
Get the thumbnail image HTML for a shopper list item, falling back to the WooCommerce placeholder when the product has no image or has been deleted.
Pre-formatting on the server lets renderers (PHP SSR + JS hydration) consume one canonical string instead of each side composing the markup from the structured images array. Mirrors the pattern WC uses in ProductSchema::price_html / ProductImage::render.
Метод класса: ShopperListItemSchema{}
Хуков нет.
Возвращает
Строку.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_image_html( ?\WC_Product $product ): string;
- ?\WC_Product $product(обязательный)
- .
Код ShopperListItemSchema::get_image_html() ShopperListItemSchema::get image html WC 11.0.1
private function get_image_html( ?\WC_Product $product ): string {
$image_id = $product instanceof \WC_Product ? (int) $product->get_image_id() : 0;
if ( $image_id > 0 ) {
return (string) wp_get_attachment_image( $image_id, 'woocommerce_thumbnail' );
}
return (string) wc_placeholder_img( 'woocommerce_thumbnail' );
}