' : $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'] ?? '', 'height' => $attributes['height'] ?? '', 'margin-top' => $attributes['style']['spacing']['margin']['top'] ?? '', 'margin-right' => $attributes['style']['spacing']['margin']['right'] ?? '', 'margin-bottom' => $attributes['style']['spacing']['margin']['bottom'] ?? 'var(--wp--preset--spacing--sm)', // TODO: Get from theme.json. 'margin-left' => $attributes['style']['spacing']['margin']['left'] ?? '', ]; $figure->setAttribute( 'style', css_array_to_string( $css ) . ';' . $figure->getAttribute( 'style' ) ); } return $dom->saveHTML(); }