Fixing links on an exported WordPress Blog with MySQL Replace

One we problem I ran into when exporting is that most of my resized images did not pull through. So my post would call for someImage-400×266.jpg though the import only grabbed someImage.jpg and not its variants.

The fix was pretty easy, though. I just used Replace. Do a datadump of your wp_posts table beforehand, just in case, and then:

update `wp_posts` set post_content = replace(post_content,’-400×266.jpg’,’.jpg’);

I had a few other variants like 400×300.jpg or 400×400.jpg depending on the aspect ratio — obviously you’ll want to use sizes that are in use at your own site — but but for the most part this went smashingly. Hoping that helps someone. 🙂

One thought on “Fixing links on an exported WordPress Blog with MySQL Replace

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