Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce\Renderer\Blocks

Product_Image::render_content │ protected │ WC 1.0

Render the product image block content for email.

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

Хуков нет.

Возвращает

string.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->render_content( $block_content, $parsed_block, $rendering_context ): string;
$block_content(строка) (обязательный)
Block content.
$parsed_block(массив) (обязательный)
Parsed block.
$rendering_context(Rendering_Context) (обязательный)
Rendering context.

Код Product_Image::render_content() WC 11.2.2

protected function render_content( string $block_content, array $parsed_block, Rendering_Context $rendering_context ): string {
	$product = $this->get_product_from_context( $parsed_block );
	if ( ! $product ) {
		return '';
	}

	$attributes = $this->parse_attributes( $parsed_block['attrs'] ?? array() );

	$image_data = $this->get_product_image_data( $product, $attributes );
	if ( ! $image_data ) {
		return '';
	}

	$parsed_block = $this->add_image_size_when_missing( $parsed_block, $rendering_context );
	$attributes   = $this->parse_attributes( $parsed_block['attrs'] ?? array() );

	$image_html = $this->build_image_html( $image_data, $attributes, $rendering_context );

	$inner_blocks = $this->process_inner_blocks( $parsed_block, $product, $rendering_context );

	$combined_content = $this->create_overlay_structure(
		$image_html,
		$inner_blocks['badges'],
		$inner_blocks['other_content'],
		$inner_blocks['badge_alignment'],
		$product,
		$attributes['showProductLink']
	);

	return $this->apply_email_wrapper( $combined_content, $parsed_block, $rendering_context );
}