Automattic\WooCommerce\Blocks\BlockTypes

FeaturedItem::get_bg_styles()publicWC 1.0

Get the styles for the wrapper element (background image, color).

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

Хуков нет.

Возвращает

Строку.

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

$FeaturedItem = new FeaturedItem();
$FeaturedItem->get_bg_styles( $attributes, $image_url );
$attributes(массив) (обязательный)
Block attributes.
По умолчанию: empty array
$image_url(строка) (обязательный)
Item image url.

Код FeaturedItem::get_bg_styles() WC 8.7.0

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