旌旗博客

2007-02-01

Upload image with Windows Live Writer

Filed under: I.T. — 标签: — rocky @ 17:37

Windows Live Writer (wlw) is a cool blog tool. But sometimes I got a error message from wlw while my post had an image within. My blog system is WordPress 2.1 running on PHP 5.20. Here is a solution:

Modify from line 138 of wp-includes/class-IXR.php as below:

 

    function parse() {
        // first remove the XML declaration
       $rx = '/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m';
       if (preg_match($rx, $this->message, $m)) {
               $encoding = strtoupper($m[1]);
       } else {
               $encoding = "UTF-8";
       }
//        $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
//        if (trim($this->message) == '') {
//            return false;
//        }
        $this->_parser = xml_parser_create($encoding);

    
Now I succeeded in uploading those magnificent pictures which have special characters in its file name.

Powered by WordPress