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

Image::get_caption_styles │ private │ WC 1.0

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() code WC 11.1.2

private function get_caption_styles( Rendering_Context $rendering_context, array $parsed_block ): string {
	$theme_data = $rendering_context->get_theme_json()->get_data();

	$align  = $parsed_block['attrs']['align'] ?? '';
	$styles = array(
		'text-align' => $align ? 'center' : $rendering_context->get_default_text_align(),
	);

	$styles['font-size'] = $parsed_block['email_attrs']['font-size'] ?? $theme_data['styles']['typography']['fontSize'];
	return \WP_Style_Engine::compile_css( $styles, '' );
}