Automattic\WooCommerce\Blocks\BlockTypes
FeaturedItem::render_image()
Renders the featured image
Метод класса: FeaturedItem{}
Хуков нет.
Возвращает
Строку
.
Использование
// private - только в коде основоного (родительского) класса $result = $this->render_image( $attributes, $item, $image_url );
- $attributes(массив) (обязательный)
- Block attributes.
По умолчанию: empty array - $item(\WC_Product|\WP_Term) (обязательный)
- Item object.
- $image_url(строка) (обязательный)
- Item image url.
Код FeaturedItem::render_image() FeaturedItem::render image WC 7.7.2
private function render_image( $attributes, $item, string $image_url ) { $style = sprintf( 'object-fit: %s;', $attributes['imageFit'] ); if ( $this->hasFocalPoint( $attributes ) ) { $style .= sprintf( 'object-position: %s%% %s%%;', $attributes['focalPoint']['x'] * 100, $attributes['focalPoint']['y'] * 100 ); } if ( ! empty( $image_url ) ) { return sprintf( '<img alt="%1$s" class="wc-block-%2$s__background-image" src="%3$s" style="%4$s" />', wp_kses_post( $attributes['alt'] ?: $this->get_item_title( $item ) ), $this->block_name, $image_url, $style ); } return ''; }