You are here

public function Embed::processEmbeds in CKEditor Media Embed Plugin 8

Replace all oembed tags with the embed html based ona provider resource.

Parameters

string $text: The HTML string to replace <oembed> tags.

Return value

string The HTML with all the <oembed> tags replaced with their embed html.

Overrides EmbedInterface::processEmbeds

File

src/Embed.php, line 161

Class

Embed
The default CKEditor Media Embed class.

Namespace

Drupal\ckeditor_media_embed

Code

public function processEmbeds($text) {
  $document = Html::load($text);
  $xpath = new \DOMXPath($document);
  foreach ($xpath
    ->query('//oembed') as $node) {
    $embed = $this
      ->getEmbedObject($node->nodeValue);
    if (!empty($embed) && !empty($embed->html)) {
      $this
        ->swapEmbedHtml($node, $embed);
    }
  }
  return Html::serialize($document);
}