MailPoet\EmailEditor\Integrations\Core\Renderer\Blocks

Image::get_caption_styles()privateWC 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.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->get_caption_styles( $settings_controller, $parsed_block ): string;
$settings_controller(Settings_Controller) (required)
Settings controller.
$parsed_block(array) (required)
Parsed block.

Image::get_caption_styles() code WC 9.8.1

private function get_caption_styles( Settings_Controller $settings_controller, array $parsed_block ): string {
	$theme_data = $settings_controller->get_theme()->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, '' );
}