Automattic\WooCommerce\Blocks\BlockTypes
ProductCategories::get_image_html() public WC 1.0
Returns the category image html
{} Это метод класса: ProductCategories{}
Хуков нет.
Возвращает
Строку
. Ничего.
Использование
$ProductCategories = new ProductCategories(); $ProductCategories->get_image_html( $category, $attributes, $size );
- $category(\WP_Term) (обязательный)
- Term object.
- $attributes(массив) (обязательный)
- Block attributes.
По умолчанию: empty array - $size(строка)
- Image size.
По умолчанию: 'woocommerce_thumbnail'
Код ProductCategories::get_image_html() ProductCategories::get image html WC 5.2.2
public function get_image_html( $category, $attributes, $size = 'woocommerce_thumbnail' ) {
if ( empty( $attributes['hasImage'] ) ) {
return '';
}
$image_id = get_term_meta( $category->term_id, 'thumbnail_id', true );
if ( ! $image_id ) {
return '<span class="wc-block-product-categories-list-item__image wc-block-product-categories-list-item__image--placeholder">' . wc_placeholder_img( 'woocommerce_thumbnail' ) . '</span>';
}
return '<span class="wc-block-product-categories-list-item__image">' . wp_get_attachment_image( $image_id, 'woocommerce_thumbnail' ) . '</span>';
}