Forums

uploaded images. why absolute urls? It's so stupid! (6 posts)

  1. teo8976
    Member
    Posted 5 months ago #

    I've just changed the domain name of my website hosting a wordpress installation.
    After changing the domain name from olddomain.org to newdomain.org, I have properly changed the general settings with the new site url.
    The blog works fine but...

    ...Images uploaded before the name change and embedded into articles posted before the change, are not shown. Why? Simple: because the URL of the images in the html code is absolute: http://www.olddomain.org/path/someimage.jpg

    That is SO RIDICOLOUS!!! Why shouldn't wordpress simply generate RELATIVE urls such as somepath/someimage.jpg????

    Ok there are plugins for automatically updating all url but they shouldn't be necessary.

    I can't see why the editor generates a whole absolute url, that's simply, simply, simply stupid.

  2. mfields
    Member
    Posted 5 months ago #

    While I can agree with your frustration here, there is a very logical explanation for this... permalinks. If you did not have permalinks turned on, relative urls would work just fine everywhere a post can be displayed.

    On my blog, I use the "Day and name" based permalinks.

    This means that a post can be displayed at anyone of the following urls:

    http://example.com/
    http://example.com/2009/06/13/sample-post/
    http://example.com/category/tacos/
    http://example.com/tags/tacos/

    There is no relative path that satisfies all of these combination.

    Hope this helps!

  3. macsolve
    Member
    Posted 1 month ago #

    mfields, a relative path from root would work in all those cases, wouldn't it?
    /path/someimage.jpg

  4. icanlocalize
    Member
    Posted 1 month ago #

    The problem, as I see it is that there uploads are just files and are not associated with any object in the database.

    If they had DB entries, registering them, it would have been possible to access the files in different ways. The permalink would have been calculated in real time, based on the permalink structure.

    As it is now, the only thing that identifies files is their path on the hard drive, so there's not much to do about it.

  5. mfields
    Member
    Posted 1 month ago #

    mfields, a relative path from root would work in all those cases, wouldn't it?
    /path/someimage.jpg

    Definitely not on my development machine :)

  6. Ipstenu
    Member
    Posted 1 month ago #

    A relative path, while a nice idea, is as problematic as an absolute URL. At least with an absolute, you can search/replace in the database fairly easily.

    And as anyone who's moved their content folder knows, it's a pain in the ass!

Reply

You must log in to post.

About this Topic