1

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.

enter image description here

1

Changing the home and siteurl in your wp_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:

  1. Go and download Interconnect IT's Database Search & Replace Script here
  2. Unzip the file and drop the folder in your localhost where your WordPress is installed (the root) and rename the folder to replace (screenshot)
  3. Navigate to the new folder you created in your browser (ex: http://localhost/wordpress/replace) and you will see the search/replace tool
  4. It should be pretty self-explanatory up to this point: enter your old URL in the search for… field and the new URL in the replace with… field

You 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.

0

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 the index.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.

  • Check the image I added. That's the strange thing. On the domain the image shows up even though the url points to an image that doesn't exist. I searched/replaced everything like I always do, never had this issue. It's weird. I deactivated the cache and still 404. I repeated this process a couple times, same thing. – elclanrs Aug 15 '13 at 5:43
  • Have you cleared your browser cache? What kind of plugins do you have installed? Although I can't imagine a caching plugin would do that as all the one's I've looked at use output caching just to take the load off the DB and PHP DOM building. But you're still loading assets from the server. – George Yates Aug 15 '13 at 5:46
  • I'm in the process of rebuilding all the thumbnails with wordpress.org/plugins/ajax-thumbnail-rebuild. 2 out of 259, 3 out of 259... let's see how it goes. I deactivated the Super Cache plugin in localhost and problem persists. – elclanrs Aug 15 '13 at 5:50
  • Good luck. I've had good results with this option if that doesn't help. – George Yates Aug 15 '13 at 5:52
  • Finished, didn't work. I'm thinking that maybe some images have been uploaded with different permissions, so they don't show up in the FTP with my credentials. I may have to contact the client and see if this is the problem, because the images show up in the domain but not in the FTP. Can't think of anything else other than that... – elclanrs Aug 15 '13 at 5:58
0

Possibly it's permissions. Go to the wp-content folder in the console and type:

chmod -R 767 uploads

Codex permissions info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.