function media_url_filter in D7 Media 7
Filter callback for media url filter. @TODO: There are currently problems with this. For instance, if a file is to be loaded from a remote location here, it will be recreated multiple times, each time this filter is called. If we want to continue supporting this feature, we would need to probably create a new stream or other way to lookup a remote file w/ its local version. Probably best as a contributed module because of this difficulty. ~ aaron.
File
- includes/
media.filter.inc, line 225 - Functions related to the WYSIWYG editor and the media input filter.
Code
function media_url_filter($text, $filter) {
$text = ' ' . $text . ' ';
// Need to attach the variables to the callback after the regex.
$callback = _media_url_curry('_media_url_parse_full_links', 1);
// Match absolute URLs.
$text = preg_replace_callback("`(<p>|<li>|<br\\s*/?>|[ \n\r\t\\(])((http://|https://)([a-zA-Z0-9@:%_+*~#?&=.,/;-]*[a-zA-Z0-9@:%_+*~#&=/;-]))([.,?!]*?)(?=(</p>|</li>|<br\\s*/?>|[ \n\r\t\\)]))`i", $callback, $text);
return $text;
}