Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Gallery::render_content
Renders the gallery block content using a table-based layout.
Метод класса: Gallery{}
Хуков нет.
Возвращает
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.
Код Gallery::render_content() Gallery::render content WC 11.2.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 );
}