public function App::filterText in Convert Media Tags to Markup 2.x
Same name and namespace in other branches
- 8 src/ConvertMediaTagsToMarkup/App.php \Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkup\App::filterText()
Filter text.
The is the heart of this module: change media tags code to an actual image tag. This can be done by the filter plugin or by the DbReplacer object.
Parameters
string $text: The text to filter.
Return value
string The filtered text.
Throws
Exception
File
- src/
ConvertMediaTagsToMarkup/ App.php, line 33
Class
- App
- Represents the Closest Zip Code API.
Namespace
Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkupCode
public function filterText(string $text) : string {
$rendered_text = $text;
$count = 1;
preg_match_all(self::MEDIA_WYSIWYG_TOKEN_REGEX, $text, $matches);
if (!empty($matches[0])) {
foreach ($matches[0] as $match) {
$replacement = $this
->tokenToMarkup([
$match,
], FALSE);
$rendered_text = str_replace($match, $replacement, $rendered_text, $count);
}
}
return $rendered_text;
}