WordPress.org

Ready to get started?Download WordPress

Forums

Relative Images (9 posts)

  1. mystifier
    Member
    Posted 3 years ago #

    I have sites with hundreds of images stored at wp-content/images

    On the live server, <img src="/wp-content/images/.." works fine.

    On the development (localhost) server, I have to use <img src="sitename/wp-content/images.."

    I don't really want to have a different directory structure online; is there a way of avoiding having to replace every reference for every update?

    'WordPress URL' and 'Site URL' don't seem to be the answer.

  2. keesiemeijer
    moderator
    Posted 3 years ago #

    You can do a search and replace with this plugin: http://wordpress.org/extend/plugins/search-regex/

  3. mystifier
    Member
    Posted 3 years ago #

    Thanks keesiemeijer, but this is effectively what I am doing now but would like to avoid.

    Aside from the baseurl, I would like to have a database that was otherwise the same both on and off line with relatively addressed images and links.

  4. keesiemeijer
    moderator
    Posted 3 years ago #

  5. mystifier
    Member
    Posted 3 years ago #

    Thanks again keesiemeijer, but this still doesn't give me what I want; this cleans permalinks from absolute to root relative (which they would be far better being anyway).

    I have lots of images in hundreds of posts in the database and I would like them to be the same on both localhost and live sites so that I don't have to change hundreds of records every single time I upload/download.

    The fundamental problem is that the root of the site is http://www.sitename.com or localhost/sitename (which is a level off webserver root).

    WordPress just doesn't seem capable of handling it. I don't know if I can do something such as an Alias in httpd.conf.

  6. keesiemeijer
    moderator
    Posted 3 years ago #

    I don't know if this is a solution on your localhost. In my computers host file I have this :

    127.0.0.1 localhost
    127.0.0.1 sitename.dev

    now when I browse to my localhost site I go to http://sitename.dev

    This is how I achieved this virtual host: http://wordpress.org/support/topic/wordpress-3-network-multisite-on-a-local-development-site?replies=49

  7. mystifier
    Member
    Posted 3 years ago #

    Thanks again keesiemeijer.

    I think you have confirmed that there is nothing within WordPress to handle this so I need to look at an external fix.

    It is pretty normal to have several development websites under localhost so it would be a nice future feature to be able to accommodate relative path images.

  8. keesiemeijer
    moderator
    Posted 3 years ago #

    Well, with virtual hosts you can have multiple development websites with normal urls. Can't you use the relative url fix from a few posts back? It is a bit of a hassle to set up multiple virtual hosts but once it's working it is so easy to set up a new development website.

  9. mystifier
    Member
    Posted 3 years ago #

    Thanks keesiemeijer.

    I will try for an httpd.conf solution because there are numerous websites running under localhost and I like to keep code hacks to a minimum.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.