Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Image::get_caption_styles
This method configure the font size of the caption because it's set to 0 for the parent element to avoid unexpected white spaces We try to use font-size passed down from the parent element $parsedBlock['email_attrs']['font-size'], but if it's not set, we use the default font-size from the email theme.
Method of the class: Image{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->get_caption_styles( $rendering_context, $parsed_block ): string;
- $rendering_context(Rendering_Context) (required)
- Rendering context.
- $parsed_block(array) (required)
- Parsed block.
Image::get_caption_styles() Image::get caption styles code WC 10.6.2
private function get_caption_styles( Rendering_Context $rendering_context, array $parsed_block ): string {
$theme_data = $rendering_context->get_theme_json()->get_data();
$styles = array(
'text-align' => isset( $parsed_block['attrs']['align'] ) ? 'center' : 'left',
);
$styles['font-size'] = $parsed_block['email_attrs']['font-size'] ?? $theme_data['styles']['typography']['fontSize'];
return \WP_Style_Engine::compile_css( $styles, '' );
}