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
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.
Thx…I tried that before I believe and just now and it didn’t work…
Try again. I made an error. The post has been edited. Sorry.
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.
Ah, yes, WordPress uses URI paths for everything.
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…
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.
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
<img src=“/wp-content/themes/Newport_Sports_Club/IMAGES/sports-club.gif” width=“613” height=“357” alt=“Gym bulding photo” id=“Building” />
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 [noparse]http://mysite.com/wp-content/themes/Newport_Sports_Club/IMAGES/sports-club.gif[/noparse]). 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]
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).