Automattic\WooCommerce\Blocks\BlockTypes

FeaturedItem::render_bg_image │ private │ WC 1.0

Renders the featured image as a div background.

Метод класса: FeaturedItem{}

Хуков нет.

Возвращает

string.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->render_bg_image( $attributes, $item );
$attributes(массив) (обязательный)
Block attributes.
По умолчанию: empty array
$item(WC_Product|\WP_Term) (обязательный)
Item object.

Код FeaturedItem::render_bg_image() WC 11.2.1

private function render_bg_image( $attributes, $item ) {
	$image_url = $this->get_image_url( $attributes, $item );
	$styles    = $this->get_bg_styles( $attributes, $image_url );

	$classes = [ "wc-block-{$this->block_name}__background-image" ];

	if ( $attributes['hasParallax'] ) {
		$classes[] = ' has-parallax';
	}

	return sprintf( '<div class="%1$s" style="%2$s" /></div>', esc_attr( implode( ' ', $classes ) ), esc_attr( $styles ) );
}