Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Image::get_inner_image_border_radius
Get the border radius to apply to the image so it sits flush inside the bordered wrapper cell.
The border is rendered on the wrapper cell, so the image radius is reduced by the border width (clamped to 0). Returns a CSS value (single radius or a four-value shorthand), or an empty string when there's no radius to apply.
Method of the class: Image{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->get_inner_image_border_radius( $parsed_block ): string;
- $parsed_block(array) (required)
- Parsed block.
Image::get_inner_image_border_radius() Image::get inner image border radius code WC 11.1.2
private function get_inner_image_border_radius( array $parsed_block ): string {
$border = $parsed_block['attrs']['style']['border'] ?? array();
$class_name = $parsed_block['attrs']['className'] ?? '';
$is_rounded = strpos( $class_name, 'is-style-rounded' ) !== false;
$radius = $border['radius'] ?? null;
if ( $is_rounded ) {
$radius = '9999px'; // Matches the circle radius applied by apply_rounded_style().
}
if ( empty( $radius ) ) {
return '';
}
// Use the widest border side so the image never pokes out past the border on any corner.
$border_width = $this->get_max_border_width( $border );
if ( is_array( $radius ) ) {
$top_left = $this->reduce_radius_by_border_width( $radius['topLeft'] ?? null, $border_width );
$top_right = $this->reduce_radius_by_border_width( $radius['topRight'] ?? null, $border_width );
$bottom_right = $this->reduce_radius_by_border_width( $radius['bottomRight'] ?? null, $border_width );
$bottom_left = $this->reduce_radius_by_border_width( $radius['bottomLeft'] ?? null, $border_width );
if ( $top_left === $top_right && $top_right === $bottom_right && $bottom_right === $bottom_left ) {
return $top_left;
}
return "{$top_left} {$top_right} {$bottom_right} {$bottom_left}";
}
return $this->reduce_radius_by_border_width( $radius, $border_width );
}