wc_get_brand_thumbnail_image()
Helper function :: wc_get_brand_thumbnail_image function.
Hooks from the function
Return
String
.
Usage
wc_get_brand_thumbnail_image( $brand, $size );
- $brand(object) (required)
- Brand term.
- $size(string)
- Thumbnail image size.
Default: ''
Changelog
Since 9.4.0 | Introduced. |
wc_get_brand_thumbnail_image() wc get brand thumbnail image code WC 9.5.1
function wc_get_brand_thumbnail_image( $brand, $size = '' ) { $thumbnail_id = get_term_meta( $brand->term_id, 'thumbnail_id', true ); if ( '' === $size || 'brand-thumb' === $size ) { /** * Filter the brand's thumbnail size. * * @since 9.4.0 * * @param string $size Brand's thumbnail size. */ $size = apply_filters( 'woocommerce_brand_thumbnail_size', 'shop_catalog' ); } if ( $thumbnail_id ) { $image_src = wp_get_attachment_image_src( $thumbnail_id, $size ); $image_src = $image_src[0]; $dimensions = wc_get_image_size( $size ); $image_srcset = function_exists( 'wp_get_attachment_image_srcset' ) ? wp_get_attachment_image_srcset( $thumbnail_id, $size ) : false; $image_sizes = function_exists( 'wp_get_attachment_image_sizes' ) ? wp_get_attachment_image_sizes( $thumbnail_id, $size ) : false; } else { $image_src = wc_placeholder_img_src(); $dimensions = wc_get_image_size( $size ); $image_srcset = false; $image_sizes = false; } // Add responsive image markup if available. if ( $image_srcset && $image_sizes ) { $image = '<img src="' . esc_url( $image_src ) . '" alt="' . esc_attr( $brand->name ) . '" class="brand-thumbnail" width="' . esc_attr( $dimensions['width'] ) . '" height="' . esc_attr( $dimensions['height'] ) . '" srcset="' . esc_attr( $image_srcset ) . '" sizes="' . esc_attr( $image_sizes ) . '" />'; } else { $image = '<img src="' . esc_url( $image_src ) . '" alt="' . esc_attr( $brand->name ) . '" class="brand-thumbnail" width="' . esc_attr( $dimensions['width'] ) . '" height="' . esc_attr( $dimensions['height'] ) . '" />'; } return $image; }