Automattic\WooCommerce\Blocks\BlockTypes

FeaturedItem::render_bg_image │ private │ WC 1.0

Renders the featured image as a div background.

Method of the class: FeaturedItem{}

No Hooks.

Returns

string.

Usage

// private - for code of main (parent) class only
$result = $this->render_bg_image( $attributes, $item );
$attributes(array) (required)
Block attributes.
Default: empty array
$item(WC_Product|\WP_Term) (required)
Item object.

FeaturedItem::render_bg_image() code WC 11.1.2

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