Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 02-16-2015, 01:02 PM   #1
Baseband Member
 
Join Date: Jul 2014
Location: USA
Posts: 29
Default Relative Hyperlinks with Images

Here is how I am attempting to do this:
< img src="../yurt.jpg" alt="Pacific Trails Yurts" width="295" height="215">

The image is located one level up from the main folder that I have the webpage in. And as of now, it does not display the image only the alternate text, which means I am not linking it correctly. Also is there a way to do with an external style sheet, as I have images referenced in that which are also located one level up from the main folder.

background-image: url(ptrbackground.jpg);
list-style-image: url(marker.gif);


Also I don't know if this matters, but I am using Web Expressions 4 program. Thanks
__________________

megan1989 is offline   Reply With Quote
Old 02-16-2015, 04:06 PM   #2
Baseband Member
 
Join Date: Jul 2014
Location: USA
Posts: 29
Default Re: Relative Hyperlinks with Images

Okay, apparently I was not going far enough back with the relative hyperlink it was solved by issuing this to the code "Pacific/images/yurt.jpg"
__________________

megan1989 is offline   Reply With Quote
Old 02-17-2015, 05:41 PM   #3
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,003
Default Re: Relative Hyperlinks with Images

So you page is located inside a folder inside the images folder?
That's a weird setup!
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 02-18-2015, 08:36 PM   #4
Baseband Member
 
Join Date: Jul 2014
Location: USA
Posts: 29
Default Re: Relative Hyperlinks with Images

Maybe I misunderstood you, but my webpage is located inside a main folder and inside the main folder is another folder with the images. I suppose it does sound a bit weird, but I promise this makes my folders seem more organized. Thank you for your reply.
megan1989 is offline   Reply With Quote
Old 02-19-2015, 05:01 AM   #5
Fully Optimized
 
joedaman633's Avatar
 
Join Date: Apr 2012
Location: England, Birmingham
Posts: 1,812
Default Re: Relative Hyperlinks with Images

Oh that's normal (same as me anyway) you should get away with just putting "/images/yurt.jpg" if you want to clean it up
__________________
Athlon II x4 645 || 1TB 7200rpm HDD || EVGA GTX 650Ti OC || 8GB DDR3 RAM || Windows 7 Home x64

i5 4210M || 500GB Samsung EVO 850 SSD || GeForce 825M || 16GB DDR3 RAM || Windows 10 x64
joedaman633 is offline   Reply With Quote
Old 02-25-2015, 06:15 AM   #6
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,003
Default Re: Relative Hyperlinks with Images

what I mean is.

consider the path

c:\websites\Pacific\pages\main.html
c:\websites\Pacific\images\yurt.jpg

< img src="../yurt.jpg" alt="Pacific Trails Yurts" width="295" height="215">

this doesn't work, because the link is located at c:\websites\pacific\pages, and is just ../ (go up one) so it's looking for the image file in c:\website\pacific\yurt.jpg and failing.

using an absolute (Pacific/images/yurt.jpg) instead of relative (../images/yurt.jpg)
will work, however, if your relative link is correct, both ways will work, (provided you don't go out of the site*)

when you say that your images are located one folder up from your page data it sounds like your folder stucture is
c:\websites\pacific\images\yurt.jog
c:\websites\pacific\images\pages\main.html (then just linking ../yurt.jpg should have worked!)

*when I say don't go outside the folder I mean that you have a thing configured either as a source directory in IIS or as a document root in apache.

if c:\websites\pacific is the document root for the pacific website,
no matter how many ../'s you put you can't traverse up the tree further than the document root.
so when you land on the site you land at c:\websites\pacific\index.html you can't run ../../windows/system32/cmd.exe!

but also you can't use data from other sites.
so c:\websites\pacific\index.html can't load objects from
c:\websites\atlantic\images\ because they are different websites, -linking using /atlantic/images won;t help either, you;d have to use http://www.atlanticsite.com/images/link

(that's why I was confused about your folder structure.
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 02-25-2015, 06:17 PM   #7
Baseband Member
 
Join Date: Jul 2014
Location: USA
Posts: 29
Default Re: Relative Hyperlinks with Images

Thank you for your reply, that makes sense. I will make a note of that information you provided, so hopefully I won't run into that error again.
__________________

megan1989 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 01:47 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0