getAttribute( 'src' ) ) {
return $html;
}
$attributes = $block['attrs'] ?? [];
$html = ! $html ? '
' : $html;
$dom = dom( $html );
$figure = get_dom_element( 'figure', $dom );
$styles = css_array_to_string( add_block_support_color( [], $attributes ) );
$svg = '';
$svg_dom = dom( $svg );
$svg_element = get_dom_element( 'svg', $svg_dom );
$result = $dom->importNode( $svg_element, true );
$img = get_dom_element( 'img', $figure );
if ( $img ) {
$figure->removeChild( $img );
}
if ( $figure ) {
$figure->appendChild( $result );
$figure->setAttribute( 'class', $figure->getAttribute( 'class' ) . ' is-placeholder' );
$css = [
'width' => $attributes['width'] ?? null,
'height' => $attributes['height'] ?? null,
'margin-top' => $attributes['style']['spacing']['margin']['top'] ?? null,
'margin-right' => $attributes['style']['spacing']['margin']['right'] ?? null,
'margin-bottom' => $attributes['style']['spacing']['margin']['bottom'] ?? 'var(--wp--preset--spacing--sm)',
// TODO: Get from theme.json.
'margin-left' => $attributes['style']['spacing']['margin']['left'] ?? null,
];
$figure->setAttribute( 'style', css_array_to_string( $css ) . ';' . $figure->getAttribute( 'style' ) );
}
return $dom->saveHTML();
}