Automattic\WooCommerce\Blocks\BlockTypes

FeaturedItem::render_bg_image()privateWC 1.0

Renders the featured image as a div background.

Method of the class: FeaturedItem{}

No Hooks.

Return

String.

Usage

// private - for code of main (parent) class only
$result = $this->render_bg_image( $attributes, $image_url );
$attributes(array) (required)
Block attributes.
Default: empty array
$image_url(string) (required)
Item image url.

FeaturedItem::render_bg_image() code WC 9.4.2

private function render_bg_image( $attributes, $image_url ) {
	$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 ) );
}