Automattic\WooCommerce\Blocks\BlockTypes
FeaturedItem::get_bg_styles()
Get the styles for the wrapper element (background image, color).
Method of the class: FeaturedItem{}
No Hooks.
Return
String
.
Usage
$FeaturedItem = new FeaturedItem(); $FeaturedItem->get_bg_styles( $attributes, $image_url );
- $attributes(array) (required)
- Block attributes.
Default: empty array - $image_url(string) (required)
- Item image url.
FeaturedItem::get_bg_styles() FeaturedItem::get bg styles code WC 9.4.2
public function get_bg_styles( $attributes, $image_url ) { $style = ''; if ( $attributes['isRepeated'] || $attributes['hasParallax'] ) { $style .= "background-image: url($image_url);"; } if ( ! $attributes['isRepeated'] ) { $style .= 'background-repeat: no-repeat;'; $bg_size = 'cover' === $attributes['imageFit'] ? $attributes['imageFit'] : 'auto'; $style .= 'background-size: ' . $bg_size . ';'; } if ( $this->hasFocalPoint( $attributes ) ) { $style .= sprintf( 'background-position: %s%% %s%%;', $attributes['focalPoint']['x'] * 100, $attributes['focalPoint']['y'] * 100 ); } $global_style_style = StyleAttributesUtils::get_styles_by_attributes( $attributes, $this->global_style_wrapper ); $style .= $global_style_style; return $style; }