public function OEmbedFilter::process in Gutenberg 8
Process each URL.
Overrides FilterInterface::process
File
- src/
Plugin/ Filter/ OEmbedFilter.php, line 39
Class
- OEmbedFilter
- Class OEmbedFilter.
Namespace
Drupal\gutenberg\Plugin\FilterCode
public function process($text, $langcode) {
$blocks = preg_split('/^.?(\\n)?$/m', $text);
$blocks = preg_replace_callback('/^(<figure.*?class=".*wp-block-embed.*">)\\s*(https?:\\/\\/\\S+?)\\s*(.*?<\\/figure>)?$/m', [
$this,
'embed',
], $blocks);
$text = implode("\n", $blocks);
return new FilterProcessResult($text);
}