Automattic\WooCommerce\Blocks\BlockTypes
FeaturedItem::render_bg_image
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, $image_url );
- $attributes(array) (required)
- Block attributes.
Default:empty array - $image_url(string) (required)
- Item image url.
FeaturedItem::render_bg_image() FeaturedItem::render bg image code WC 10.8.1
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 ) );
}