MailPoet\EmailEditor\Integrations\Core\Renderer\Blocks
Image::apply_image_border_style()
Apply border style to the image.
Method of the class: Image{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->apply_image_border_style( $block_content, $parsed_block, $class_name ): string;
- $block_content(string) (required)
- Block content.
- $parsed_block(array) (required)
- Parsed block.
- $class_name(string) (required)
- Class name.
Image::apply_image_border_style() Image::apply image border style code WC 9.8.1
private function apply_image_border_style( string $block_content, array $parsed_block, string $class_name ): string { // Getting individual border properties. $border_styles = wp_style_engine_get_styles( array( 'border' => $parsed_block['attrs']['style']['border'] ?? array() ) ); $border_styles = $border_styles['declarations'] ?? array(); if ( ! empty( $border_styles ) ) { $border_styles['border-style'] = 'solid'; $border_styles['box-sizing'] = 'border-box'; } $border_element_tag = array( 'tag_name' => 'td', 'class_name' => 'email-image-cell', ); $content_with_border_styles = $this->add_style_to_element( $block_content, $border_element_tag, \WP_Style_Engine::compile_css( $border_styles, '' ) ); // Add Border related classes to proper element. This is required for inlined border-color styles when defined via class. $border_classes = array_filter( explode( ' ', $class_name ), function ( $class_name ) { return strpos( $class_name, 'border' ) !== false; } ); $html = new \WP_HTML_Tag_Processor( $content_with_border_styles ); if ( $html->next_tag( $border_element_tag ) ) { $class_name = $html->get_attribute( 'class' ) ?? ''; $border_classes[] = $class_name; $html->set_attribute( 'class', implode( ' ', $border_classes ) ); } return $html->get_updated_html(); }