brianbam — 2013-05-18T23:45:35-04:00 — #1
I'm trying to create a relative link for an image, but I can get it to work for some reason. The page and the images folder are in the same folder.
Why doesn't this path work?
<img src="..IMAGES/sports-club.gif" width="613" height="357" alt="Gym bulding photo" id="Building" />
This is the site
ronpat — 2013-05-19T00:03:17-04:00 — #2
file addressing notation:
../dirname/filename (from the parent directory, go to path/filename )
./dirname/filename (from the current directory, go to path/filename )
/dirname/filename (absolute addressing; relative to the root directory, go to /path/filename )
dirname/filename (same as ./)(from the current directory, go to path/filename )
Delete the two dots before IMAGES.
brianbam — 2013-05-19T00:06:40-04:00 — #3
Thx...I tried that before I believe and just now and it didn't work.....
ronpat — 2013-05-19T00:09:56-04:00 — #4
Try again. I made an error. The post has been edited. Sorry.
brianbam — 2013-05-19T00:11:55-04:00 — #5
ralphm — 2013-05-19T00:14:59-04:00 — #6
This is the relative path to your images:
In a WP site, the "page" and the images folder are not usually (if ever) in the same folder.
ronpat — 2013-05-19T00:18:46-04:00 — #7
Ah, yes, WordPress uses URI paths for everything.
brianbam — 2013-05-19T00:43:00-04:00 — #8
Well, what folder is the page and style sheet supposed to be in then? I have 4 sites and they all have the pages in the theme's name folder (i.e.
wp-content/themes/theme_name/index.php or header.php, etc.)
And the images folder is in the same same folder as the index.php file.
I feel like there is something missing here....
ralphm — 2013-05-19T01:03:42-04:00 — #9
Forget about page location in WP, as pages are dynamically created and have no actual "location". If you want buttetproof image links, always use this on this particular site:
Note the / at the front. That way, the link will work from any part of the site, even in the stylesheet links.
ronpat — 2013-05-19T01:06:53-04:00 — #10
If the path that Ralph posted began with a slash, it would be an absolute path and should work from either the css or index page.
bested by Ralph
brianbam — 2013-05-19T01:16:34-04:00 — #11
<img src="/wp-content/themes/Newport_Sports_Club/IMAGES/sports-club.gif" width="613" height="357" alt="Gym bulding photo" id="Building" />
ralphm — 2013-05-19T01:20:51-04:00 — #12
Glad we could help.
There's a lot of argument over whether that should be called "absolute" or not, and these days I side with those who call it a "root relative" path, reserving "absolute" for the full URL (such as http://mysite.com/wp-content/themes/Newport_Sports_Club/IMAGES/sports-club.gif). Only the full URL is truly absolute, as it works from anywhere, whereas the root relative link is only absolute within the content of the site itself (it's not even absolute in relation to the server the site sits on). [/ot]
ronpat — 2013-05-19T01:22:09-04:00 — #13
BTW - the reason the following code does not work is because of the leading slash.
dots, slashes and paths matter. See post # 2.
Obviously, I lean toward the old fashioned, conventional definitions and usage.
URL or URI means "universal resource locator or indicator", as in works from anywhere.
absolute refers to a specific location (the top-most directory, on a computer).