Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Image::render_content
Renders the block content
Method of the class: Image{}
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.
Image::render_content() Image::render content code WC 10.6.2
protected function render_content( string $block_content, array $parsed_block, Rendering_Context $rendering_context ): string {
$parsed_html = $this->parse_block_content( $block_content );
if ( ! $parsed_html ) {
return '';
}
$image_url = $parsed_html['imageUrl'];
$image = $parsed_html['image'];
$caption = $parsed_html['caption'];
$class = $parsed_html['class'];
$anchor_tag_href = $parsed_html['anchor_tag_href'];
$anchor_data_link_href = $parsed_html['anchor_data_link_href'];
$parsed_block = $this->add_image_size_when_missing( $parsed_block, $image_url );
$image = $this->add_image_dimensions( $image, $parsed_block );
$image_with_wrapper = str_replace(
array( '{image_content}', '{caption_content}' ),
array( $image, $caption ),
$this->get_block_wrapper( $parsed_block, $rendering_context, $caption, $anchor_tag_href, $anchor_data_link_href )
);
$image_with_wrapper = $this->apply_rounded_style( $image_with_wrapper, $parsed_block );
$image_with_wrapper = $this->apply_image_border_style( $image_with_wrapper, $parsed_block, $class );
return $image_with_wrapper;
}