Automattic\WooCommerce\Blocks\BlockTypes
ProductCategories::get_image_html()
Returns the category image html
Method of the class: ProductCategories{}
No Hooks.
Return
String
.
Usage
$ProductCategories = new ProductCategories(); $ProductCategories->get_image_html( $category, $attributes, $size );
- $category(\WP_Term) (required)
- Term object.
- $attributes(array) (required)
- Block attributes.
Default: empty array - $size(string)
- Image size.
Default: 'woocommerce_thumbnail'
ProductCategories::get_image_html() ProductCategories::get image html code WC 9.8.1
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>'; }