Index: /MediaWiki/trunk/extensions/FCKeditor/FCKeditor.body.php
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/FCKeditor.body.php	(revision 579)
+++ /MediaWiki/trunk/extensions/FCKeditor/FCKeditor.body.php	(revision 580)
@@ -66,4 +66,5 @@
         $wgHooks['UserToggles'][]                       = $this;
         $wgHooks['MessagesPreLoad'][]                   = $this;
+        $wgHooks['ParserAfterTidy'][]                   = $this;
         $wgHooks['EditPage::showEditForm:initial'][]    = array($this, 'onEditPageShowEditFormInitial');
 
@@ -87,5 +88,18 @@
         }
     }
-
+    
+    public function onParserAfterTidy(&$parser, &$text)
+    {
+        global $wgUseTeX;
+        
+        if ($wgUseTeX) {
+            //it may add much overload on page with huge amount of math content...
+            $text = preg_replace('/<img class="tex" alt="([^"]*)"/m', '<img alt="$1" _fck_mw_math="$1"', $text);
+            $text = preg_replace("/<img class='tex' src=\"([^\"]*)\" alt=\"([^\"]*)\"/m", '<img src="$1" alt="$2" _fck_mw_math="$2"', $text);
+        }
+        
+    	return true;
+    }
+    
     public function onMessagesPreLoad()
     {
