Question

I recently inherited a large site from a developer that vanished. The site has more than 6,000 images. In the pages most of the images are missing, however, they are referenced in the media library and I can see them on the server under wp-content/uploads. When I try to access any of these images with the blank thumbnail I get the following error message:

Missing Attachment

Given that this site has been moved to a new host I am pretty sure that these images are not properly referenced but I am not sure how to modify the path to the images to get them to show up properly. I did some research and tried the following:

UPDATE wp_posts set post_content=REPLACE(post_content, 'mysitexyz.net.basepointsite.com/', 'mysitexyz.net/');

What is the correct way to re-associate these images and have them appear correctly in the media library?

Was it helpful?

Solution

There's a few plugins to fix this, but basically it your database still references the images to be "oldsite.com/wp-content/uploads/" and you need it to be "newsite.com/wp-content/uploads"

So you have to change all old references. You could use SQL:

    UPDATE wp_options SET option_value = replace(option_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl';
    UPDATE wp_posts SET guid = replace(guid, ‘http://www.oldsite.com’,’http://www.newsite.com’);
    UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.oldsite.com’, ‘http://www.newsite.com’);
    UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’);

I used to use this plugin which worked great for transferring sites.

https://wordpress.org/plugins/velvet-blues-update-urls/

And this plugin is specifically for letting you sync local and remote changes that have been made throuh ftp:

https://wordpress.org/plugins/ftp-sync/

Or here's a few other popular ones, they pretty much do the same thing:

MPress Fix URL References https://wordpress.org/plugins/mpress-fix-url-references/

Go Live Update URLS https://wordpress.org/plugins/go-live-update-urls/screenshots/

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top