If you are reading this you probably just migrated your WordPress blog from one hosting provider to the other. If everything else on your blog has been restored and its working fine then congratulations since that was the hard part.
The good news is that restoring yourÂ images is fairly straightforward, and the even better news is you won’tÂ have to manually modify all your image links. Â This should give you some relief!
Here are the steps:
- Back up your database. Many hosting providers have this functionality built-in. If you are hosting your own blog itâ€™s best to just go ahead get another freshÂ export of the database and copy it to your local machine again. This gives you the most up-to-dateÂ copy if something goes wrong in Step 6.
- Open your most recentÂ blog post that has a broken image. Copy and paste the broken URLÂ into a text editor. You should be able to figure out the broken link by clicking on the missing imageâ€™s empty holder. Example:
- Fix this one image only using the WordPress blog post editor and save your changes. Then refresh your browser and make sure the image is now displaying correctly.
IMPORTANT NOTE: In the majority ofÂ cases this step will go just fine. However, if it doesn’t thenÂ there are a few potentially tricky reasons why yourÂ changes may not show up immediately. It may depend on how your blog cache is set up, for example if you are using TotalCache you may have to manually blow away your blogs cache(s). Also some hosting providers may take a few minutes to update your data in the cloud. And, lastly you may have to delete your browser cache depending on how the web server that is hosting your blog is configured. Sorry, sometimes there’s no easy answer here, but I believe it’s better for you to be aware.
- Now click on the new image and get its URL, then copy and paste the URL to your text editor. Note in my example there are some slight differences between the old and newÂ URLs. It’s these differences that we need to correct. Example of a new URL:
- Open up the database in a SQL editor window. One popular way to access the database is via phpMyAdmin.
- In theÂ text editor create aÂ SQL UPDATE command from the URLs mentioned above that you copied and pasted then run the UPDATE command. Here’s an example template of how your command might look. Be sure to modify just the URLs so they fit your unique Blog:
UPDATE wp_posts SET post_content = REPLACE(post_content,’www.myoldsite.com/htdocs’,’www.mynewsite.com’);
- Refresh your webpage and see if all the broken image links are restored.
- If for some reason your website crashes or the pages get messed up then you will need to restore the database and start over with Step 1 above. The most common reason for any problems happening is there was a mistake made when creating the SQL UPDATE statement.