I just transferred a WordPress installation from the domain to my localhost. I did all the usual steps: copy files, export DB and replace domain.com
with localhost
, update wp-config.php
and refresh permalinks. All pages and custom rewrite rules work, but some images are giving a 404.
When I check those images on the actual domain it all works fine, but something doesn’t look right; if I check the url of the image it points to this path:
http://domain.com/wp-content/uploads/2013/08/IMG_0425-185x185.jpg
But this file doesn’t exist! I looked in the uploads folder through FTP and the file isn’t there, only IMG_0425-185x185-150x150.jpg
exists. Note that 185x185
is part of the original filename but 150x150
is added by WP.
In localhost the image doesn’t show up (404), which makes sense.
Why is the image showing up on the domain when it doesn’t even exist? Is WordPress resolving the image to the generated thumbnail somehow? Why isn’t it working on the localhost if this is the case?
Edit:
This is what makes no sense. How is this possible? Maybe the cache has something to do?
As you can see no trace of IMG_0425-185x185.jpg
in the folder (??) but IMG_0425-185x185-150x150.jpg
exists.
Changing the
home
andsiteurl
in yourwp_options
table is not enough unfortunately. You will still have your post content with your non-localhost URL (http://domain.com
) causing your website to not display properly on your localhost.Once you’ve downloaded and imported your database to your localhost. Follow these steps:
replace
(screenshot)http://localhost/wordpress/replace
) and you will see the search/replace toolsearch forâ¦
field and the new URL in thereplace withâ¦
fieldYou can click the dry run button under actions to see what it will be replacing before you execute the script. Once you’re done be sure to remove the
/replace/
folder.If it’s not there in your FTP client – therefore not on your server – it’s not going to be showing up on your site. So it’s almost certainly a caching thing in your browser, have you tried clearing it or doing a hard refresh? WordPress’s rewrite won’t fallback to the thumbnail if the original image isn’t there. the
.htaccess
will just load up theindex.php
which will throw a 404.The other thing I would check is to make sure the URL is pointed to where you think it’s pointed. WordPress stores all it’s image links as an absolute URL in the DB. And unless you do a find+replace when you transfer a site, that won’t get updated. You said you were moving the site around and it’s quite possible you’re actually loading the image from an older server.
Possibly it’s permissions. Go to the wp-content folder in the console and type:
Codex permissions info.