Jump to content
Sign in to follow this  
mauricen

Relative URLs for background image - keeps changing

Recommended Posts

mauricen

In Design Controlunder Site Background Image. I change the url to be relative as my domain will change once out of testing. I make the URL ../../../images/test.png The new background image works just fine. Then, a few minutes later, the admin resets it to http://../../../images/test.jpg and breaks the link. Why is it doing this and what is the proper way to make a relative link?

Share this post


Link to post
Share on other sites
cshoffmann

It's a WordPress thing. When you change the domain name in the WP>Settings>General area it will take care of it. No worries.

Share this post


Link to post
Share on other sites
ricardo

Yeah, that's one of the things that always nagged me about WP. If you're not using the Media Library or PlatformPro's image handling, your best option is to make the link relative to the root, meaning, instead of "../images/file.jpg" use "/somedir/images/file.jpg". Never breaks =) Ricardo

Share this post


Link to post
Share on other sites
mauricen

Ricardo, the ../../ is to go up directories, so adding another sub-directory names does nothing but take you down to a lower directory. Thanks, Shaun, for the response. One can only hope that when I directly enter the full URL (not letting the upload manager do it) that WordPress will still redirect the new URL once I move it.

Share this post


Link to post
Share on other sites
ricardo

Maurice, You didn't understand my suggestion. Take the following pages as example: A: http://site.tld/dir/subdir/subsubdir/subsubsubdir/page.html B: http://site.tld/dir/page.html When your hypertext reference starts with a forward slash, the browser follows that path from the root. So if you place your image in a folder in the root, it doesn't matter if your page as down as page A or B, "/imagefolder/file.jpg" will always display the image. But if you use paths relative to the page, those that start with "../", they will break as soon as you move the page up or down the hierarchy. Ricardo

Share this post


Link to post
Share on other sites
mauricen

You are absolutely right, Ricardo, I read that wrong. Thank you for clarifying for me. Makes perfect sense.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×