Learn how to quickly change image URLs in WordPress. Useful if you’ve recently changed your WordPress domain name and your images are no longer showing.
Changing Image URLs using Search Replace DB
Search Replace DB is a free script which makes the process of migrating PHP and MySQL based websites between domain names and web hosts simple. The script is primarily designed for WordPress but also works for most other similar CMS applications.
Search Replace DB searches and replaces content throughout your entire WordPress database, making it a perfect tool for changing image URLs. It also works with WordPress’s multisite and network feature (formerly WordPress MU).
To install. Download Search Replace DB and upload the script to your web root (or the same folder as wp-config.php). Browse to the script’s URL in your web browser and follow the on screen prompts.
Important This file can potentially allow a third-party to access your WordPress site. To prevent misuse delete the file from your web space after use.
Changing Image URLs using SQL
By default, WordPress saves links to images at the time your post or page was published. You can use the following SQL Query to update your posts to use the new URL.
We provide examples for WordPress and WordPress Multisite (formerly WordPress MU).
Update image urls in WordPress – Single site
UPDATE wp_posts SET post_content = replace(post_content, 'http://example.com', 'http://example.co.uk');
UPDATE wp_posts SET guid = replace(guid, 'http://example.com', 'http://example.co.uk');
Update image urls in WordPress – Multisite (Formerly WordPress MU)
Remember to replace 100 with the ID number of your blog.
UPDATE wp_100_posts SET post_content = replace(post_content, 'http://example.com', 'http://example.co.uk');
UPDATE wp_100_posts SET guid = replace(guid, 'http://example.com', 'http://example.co.uk');
You’ll need someway of running the above SQL queries against your WordPress database.
We recommend phpMyAdmin or installing a WordPress database like WP-DBManager which offers built-in support for SQL queries.
Remember to first backup your WordPress database before trying running your SQL query.
Reliable UK web hosting. Free tech support. Trusted UK host since 2004. Free setup. Order online.
Fast cPanel hosting with email. Choice of UK/US servers. 30-day money-back promise. Founded 2004.
- How to upload an image to your WordPress Blog
- WordPress Frequently Asked Questions
- Getting Started with Ecenica WordPress
- How to add an image to your WordPress Theme
- How to link your WordPress blog to Twitter