Index: /MediaWiki/trunk/extensions/FCKeditor/FCKeditorSajax.body.php
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/FCKeditorSajax.body.php	(revision 576)
+++ /MediaWiki/trunk/extensions/FCKeditor/FCKeditorSajax.body.php	(revision 577)
@@ -3,18 +3,24 @@
 function wfSajaxGetImageUrl( $term )
 {
-    global $wgContLang, $wgOut;
+    global $wgExtensionFunctions, $wgTitle;
 
-    $term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) );
-    $term1 = str_replace( ' ', '_', $wgContLang->ucfirst( $term ) );
-    $term2 = str_replace( ' ', '_', $wgContLang->lc( $term ) );
-    $term3 = str_replace( ' ', '_', $wgContLang->uc( $term ) );
-    $term = $term1;
+    $options = new FCKeditorParserOptions();
+    $options->setTidy(true);
+    $parser = new FCKeditorParser();
 
-    $title = new Title();
-    $nt = Title::newFromText( $term , NS_IMAGE);
-    $img   = new Image( $nt );
-    return $img->getURL();
+    if (in_array("wfCite", $wgExtensionFunctions)) {
+        $parser->setHook('ref', array($parser, 'ref'));
+        $parser->setHook('references', array($parser, 'references'));
+    }
+    $parser->setOutputType(OT_HTML);
+    $originalLink = $parser->parse("[[Image:".$term."]]", $wgTitle, $options)->getText();
+    if (false == strpos($originalLink, "src=\"")) {
+        return "";
+    }
 
-    return $ret;
+    $srcPart = substr($originalLink, strpos($originalLink, "src=")+ 5);
+    $url = strtok($srcPart, '"');
+
+    return $url;
 }
 
