Thread:Extension talk:WYSIWYG/Media: links get mangled (fully patched 1.19)/reply (5)

In /extensions/WYSIWYG/CKeditorParser.body.php add the following line: $text = preg_replace("/(\[\[)(Media:.*?\]\])/", '$1:$2', $text); just before $parserOutput = parent::parse($text, $title, $options, $linestart, $clearState, $revid); (Should be line 720)

And in the same file add: $parserOutput->setText(preg_replace('/(a href="):(Media.*?")/', '$1$2', $parserOutput->getText)); just before CKeditorLinker::removeHooks; (Should be line 777)

The first addition will change all '[[Media' links to '[[:Media'. The semi-colon prevents the parser from detecting them as media links and re-writing the URL (to /images/x/y/filename.pdf) in the edit box. The second addition removes the semi-colon once the parser has finished going through the article so that the article won't be saved with extra semi-colons.

I've tested it on 1.19.2 and 1.20.2, haven't encountered any issues on either. Hope it helps.