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. 🙂