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

Gallery::render_content │ protected │ WC 1.0

Renders the gallery block content using a table-based layout.

Method of the class: Gallery{}

No Hooks.

Returns

string.

Usage

// protected - for code of main (parent) or child class
$result = $this->render_content( $block_content, $parsed_block, $rendering_context ): string;
$block_content(string) (required)
Block content.
$parsed_block(array) (required)
Parsed block.
$rendering_context(Rendering_Context) (required)
Rendering context.

Gallery::render_content() code WC 11.1.2

protected function render_content( string $block_content, array $parsed_block, Rendering_Context $rendering_context ): string {
	// The number of columns and the available layout width determine how wide each cropped image
	// is displayed. We pass that per-image width to the crop so an image CDN can serve an
	// appropriately sized (and cropped) file.
	$columns      = $this->get_columns_from_attributes( $parsed_block['attrs'] ?? array() );
	$layout_width = (int) Styles_Helper::parse_value( $rendering_context->get_layout_width_without_padding() );

	// Extract images directly from the block content (more efficient than re-rendering).
	$gallery_images = $this->extract_images_from_gallery_content( $block_content, $parsed_block, $columns, $layout_width );

	// If we don't have any images, return empty.
	if ( empty( $gallery_images ) ) {
		return '';
	}

	// Build the email-friendly layout.
	return $this->build_email_layout( $gallery_images, $parsed_block, $block_content, $rendering_context );
}