Remove anchor tags if present
jferjan - June 16, 2007 - 14:59
| Project: | Googtube |
| Version: | 4.7.x-1.x-dev |
| Component: | code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | won't fix |
Jump to:
Description
Hi,
i made some modifications to remove anchor tags from YouTube and GoogleVideo links if present. This is especially needed if you are using TinyMCE, because TinyMCE automatically appends anchor tags to all links in Internet Explorer.
i just added two preg_replace functions to remove a tags
case 'process':
$text = ' ' . $text . ' ';
//remove anchor tags if present
$text = preg_replace('!(<a.+?href\="(http://www\.youtube\.com/watch[?]v=[^\[\]()<.,\s\n\t\r]+)"(?=[>\s]).*?>.+?</a>)!i', "$2 ", $text);
$text = preg_replace('!(<a.+?href\="(http://video\.google\.(com|ca)/videoplay[?]docid=[^\[\]()<.,\s\n\t\r]+)"(?=[>\s]).*?>.+?</a>)!i', "$2 ", $text);
//youtube regex
$text = preg_replace_callback('!(((http://)?)|(^./))(((www.)?)|(^./))youtube\.com/watch[?]v=([^\[\]()<.,\s\n\t\r]+)!i', 'googtube_youtube', $text);
//google video regex
$text = preg_replace_callback('!(((http://)?)|(^./))(((www.)?)|(^./))video\.google\.(com|ca)(\.[a-z]+)?/videoplay[?]docid=([^\[\]()<.,\s\n\t\r]+)!i', 'googtube_google', $text);
#1
Version 4.7 is not supported anymore.