Automattic\WooCommerce\Blocks\BlockTypes

ProductCategories::get_image_html()publicWC 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() WC 8.7.0

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>';
}