WordPress.org

Ready to get started?Download WordPress

Forums

Images on localhost still point to live blog (14 posts)

  1. annayevs
    Member
    Posted 2 years ago #

    Hi,
    I installed a local version of my blog. Everything seems ok, except the images.
    1. The images on the local version are pointing to the images on the live blog.
    2. The images that were designated as "featured image" for a post, are not showing up at all.

    Is it possible to change the link of all image links to point to the local folder? Is it a setting I'm missing? I have a LOT of images and I'd like to do them all at once, in a batch.

    Any help is greatly appreciated.
    Anna

  2. ClaytonJames
    Member
    Posted 2 years ago #

    a. Export the database. Make two copies and save one for a backup. Open the other one with a plain text editor that supports search and replace. Replace all instances of the actual domain name with localhost. Save and import the database. (or you can accomplish a search and replace from a command line if comfortable with mysql)

    b. Search and Replace in MySQL database with phpMyAdmin

    c. You might try a plugin option

  3. annayevs
    Member
    Posted 2 years ago #

    Thanks!
    How much of the link do I need to replace?
    If this is the URL for one of the images:
    http://annasrecipebox.com/wp-content/uploads/2011/10/Puff-Pastry-Honey-Nuts.jpg

    And my installation path looks like this:
    Applications/MAMP/htdocs/wordpress/wp_content/uploads/

    What would my new link look like?
    http://localhost/wp-content/uploads/2011/10/Puff-Pastry-Honey-Nuts.jpg?

  4. ClaytonJames
    Member
    Posted 2 years ago #

    I think you will only need to search and replace "annasrecipebox.com" with "localhost/wordpress"

    That should probably do it. Be sure to back the database up first, just in case.

    What would my new link look like?
    http://localhost/wp-content/uploads/2011/10/Puff-Pastry-Honey-Nuts.jpg?

    You might need to include the directory wordpress is installed in, so it would most likely look like this:

    http://localhost/wordpress/wp-content/uploads/2011/10/Puff-Pastry-Honey-Nuts.jpg?

  5. annayevs
    Member
    Posted 2 years ago #

    Thanks for such a prompt reply ClaytonJames. I tried several versions, just in the post before I make any changes. I tried these by just typing the URL into the address bar to see if the image would show up, and also in the post itself. None of the versions I tried worked. Here are the two that I tried:
    http://localhost/wordpress/wp-content/uploads/2011/10/Puff-Pastry-Honey-Nuts.jpg
    and
    http://localhost/wp-content/uploads/2011/10/Puff-Pastry-Honey-Nuts.jpg
    Both of these resulted in the following error message:
    Unable to connect
    Firefox can't establish a connection to the server at localhost.

    What am I doing wrong? I see the page, but the image says it can't connect...

  6. ClaytonJames
    Member
    Posted 2 years ago #

    I tried several versions, just in the post before I make any changes.I tried these by just typing the URL into the address bar to see if the image would show up, and also in the post itself.

    I'm not sure if that would work without editing the database first. (seems like direct access with an absolute url in the address bar should though)

    Unable to connect
    Firefox can't establish a connection to the server at localhost.

    Step one is to confirm your local web server is still running. What do you get when you just try http://localhost or http://localhost:8888 in your browser?

    You may also want to review the MAMP setup and port number information as well. I'm a little embarrassed to admit it, but MAMP is not on my list of often used applications.

  7. annayevs
    Member
    Posted 2 years ago #

    Hi,
    When I type in http://localhost:8888/ I see the listing of my directories. When I type in http://localhost:8888/wordpress/ I see my blog. So it looks like the servers are up.
    I'm just hesitating to make such drastic changes to the DB before testing them out first, even though this is a copy already, running only on my machine and not impacting the actual DB for the live site.

    Any additional suggestions?
    Thanks again,
    Anna

  8. ClaytonJames
    Member
    Posted 2 years ago #

    Better to err on the side of caution, and take it slow. I think what you might need to decide now is whether you want to proceed with the port number needing to being included in all of your urls or not.

    MAMP default is :8888, instead of port 80, so it needs to appear in every url to work. Any thoughts on just switching MAMP's port to port 80? That way you don't have to include the port number in your urls?

    "Once you open MAMP, click the Preferences button. Next, click over to "Ports." The default MAMP ports are 8888 for Apache, and 8889 for MySQL. If you use this configuration, you shouldn't get asked for your password, but you'd need to include the port number in the URL (localhost:8888). If you'd like to leave the port number out of the URL, change the Apache port to 80. The downside of using port 80 as your MAMP Apache port is that you'll always be asked for your password.:

    ...otherwise, I think your search and replace would need to be from "annasrecipebox.com" to "localhost:8888/wordpress"

    Basically just including the port number in your urls in the wordpress general settings. ie... http://localhost:8888/wordpress

  9. annayevs
    Member
    Posted 2 years ago #

    I don't mind changing the ports. But shouldn't this link bring up the image: http://localhost:8888/wordpress/wp-content/uploads/2011/10/Puff-Pastry-Honey-Nuts.jpg
    Now, I get this message: "No Results Found
    The page you requested could not be found. Try refining your search, or use the navigation above to locate the post.
    "
    Now I'm just confused.
    Thanks again for your help.

  10. ClaytonJames
    Member
    Posted 2 years ago #

    Now I'm just confused.

    Me too. Here's where we started:

    I installed a local version of my blog. Everything seems ok, except the images.
    1. The images on the local version are pointing to the images on the live blog.
    2. The images that were designated as "featured image" for a post, are not showing up at all.

    All of that is simply due to the fact that all of the references to all of your images, and all of the information attached to those images that was created from, or edited while in your media library, are stored in the database, and still point to the domain name for your live site.

    The solution is to do a search and replace on the database, trading old domain name for new location. There may be file and directory permissions to consider, but until you actually edit the database to properly reflect the new location, I think you're going to you have a difficult time troubleshooting any other image related issues.

    But shouldn't this link bring up the image: http://localhost:8888/wordpress/wp-content/uploads/2011/10/Puff-Pastry-Honey-Nuts.jpg

    If the image exists at that exact path, with that exact name, and its location is completely web-accessible, and you put that absolute path to the image in your browsers address bar... yes, it should be viewable in your browser.

  11. annayevs
    Member
    Posted 2 years ago #

    What table in the database do I need to update? I want to try with just one link, just to be sure before I change them all. What should I look for in the database if doing this manually?

    Thanks again for your help,
    Anna

  12. annayevs
    Member
    Posted 2 years ago #

    Any ideas of what table I should modify?

  13. esmi
    Forum Moderator
    Posted 2 years ago #

  14. annayevs
    Member
    Posted 2 years ago #

    Yes, that was suggested earlier. before I make changes to the whole DB, I want to try it on a few links first, just so I know what's happening. I want to do that manually, before doing the plugin. Any ideas where I should look in the DB?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.