protected function Embed::swapEmbedHtml in CKEditor Media Embed Plugin 8
Replace <oembed> tags with their respected embed HTML.
Parameters
\DOMNode $node: The DOMNode object of the <oembed> tag.
object $embed: The embed json decoded object as provided by Embed::getEmbedOjbect().
Return value
$this
1 call to Embed::swapEmbedHtml()
- Embed::processEmbeds in src/
Embed.php - Replace all oembed tags with the embed html based ona provider resource.
File
- src/
Embed.php, line 194
Class
- Embed
- The default CKEditor Media Embed class.
Namespace
Drupal\ckeditor_media_embedCode
protected function swapEmbedHtml(\DOMNode &$node, $embed) {
$embed_node = $node->ownerDocument
->createElement('div');
$embed_node
->setAttribute('class', $this
->getClass($embed));
$child = NULL;
$embed_body_node = Html::load(trim($embed->html))
->getElementsByTagName('body')
->item(0);
foreach ($embed_body_node->childNodes as $child) {
if ($child = $node->ownerDocument
->importNode($child, TRUE)) {
$embed_node
->appendChild($child);
}
}
$node->parentNode
->replaceChild($embed_node, $node);
return $this;
}