Unable to Load Images From WordPress XML Exports When Importing

I had an interesting situation where I had used the export tool of WordPress (via Tools > Export) to extract the data from an existing site ready to be imported into a new one as part of a migration.

As a consequence, when opening the XML file in notepad, it had a series of referenced image files of this form:

Straight-forward right? When WordPress imports the file, it would go to those URLs and download the images before importing them straight back in again.

Since it is effectively a text file, if you don’t like where they are coming from, you can just do a search and replace and make the URL be something else.

Well, it should have been easy, but the problem I had was that the SSL certificate had expired so every time it went to get an image, it failed. That led to a situation where I had the posts, comments, pages etc. but no images. Drat.

Applying an SSL certificate to the original site wasn’t going to be easy – there were other apps on that host and I didn’t want to risk hurting them or causing any downtime, so what else could I do?

There was one easy alternative and one other option that I immediately thought of.

Let’s tackle the easy one first. If you can, just install something like Updraft. From here, you can export all the data into Zip files. Then, install the plugin on your destination site, and import them back in. Assuming you are able to manipulate plugins, that is by far the simplest approach provided you haven’t changed the name of your domain.

If you can’t and you want to stick with the in-built import process, you can do the following:

On your original site, take a copy of the images and place them somewhere externally visible. I chose the same destination host and used the html folder of Apache so that I could go to:


To achieve this, let’s get the images first from your source WordPress installation:

That will give you a zipped tar file with all of the images. Now ftp (or otherwise) them to the destination host and remove the file afterwards. For now, let’s say they are located within \tmp on our destination.

Now, using the search and replace method above, you can change the location of the images by doing a search and replace using:

search: https://url.com/wp-content/uploads/

replace: http://localhost/

Lastly, import the file in as before. What’s changed is that instead of going to the site with no certificate, it is pulling the data from itself, just in a different folder.

Don’t forget to free up any unneeded space.


Written by Stephen Moon
email: stephen at logicalmoon.com
www: https://www.logicalmoon.com

Hey! Did you enjoy reading this? If you did and would like an email when I add new content, just subscribe to my list. You can unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *