Windows Live Writer Image Upload and WordPress (WPMU)

My previous post http://emad.blogstogo.com/2007/07/19/window-live-writer-and-pictures/ didn’t work right away.  When I tried to post it, I received the error message
image 

Luckily, I found the fix.  The problem was in the wp-includes/class-IXR.php.  At line 138 in function parse, I replaced:

$this->message = preg_replace(‘/<?xml(.*)??’.’>/’, ”, $this->message);
if (trim($this->message) == ”) {
    return false;
}

with:

$rx = ‘/<?xml.*encoding=[‘”](.*?)[‘”].*?>/m’;
if (preg_match($rx, $this->message, $m)) {
       $encoding = strtoupper($m[1]);
} else {
       $encoding = “UTF-8”;
}

The first few lines of my function looked like this:

        //begin WLW fix for image upload
        //commented for WLW
        /*
        $this->message = preg_replace(‘/<?xml(.*)??’.’>/’, ”, $this->message);
        if (trim($this->message) == ”) {
            return false;
        }
        */
        //replaced with WLW
        $rx = ‘/<?xml.*encoding=[‘”](.*?)[‘”].*?>/m’;
        if (preg_match($rx, $this->message, $m)) {
               $encoding = strtoupper($m[1]);
        } else {
               $encoding = “UTF-8”;
        }
        //end WLW fix

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s