Forum Moderators: mack

Message Too Old, No Replies

Image doesn't show

Please help

         

Shuvi

1:44 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



I have a header in my common folder that I'm trying to include on every page. The header contains a logo which is in a different folder on the same level. When I include it everything in the header show's up but the logo. What am I doing wrong?
Please help,
SP

korkus2000

2:18 pm on Dec 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use an absolute path.

<img src="http://www.example.com/logoimages/logo.gif">

That should fix the problem.

Shuvi

6:43 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



thanks! Got it to work!

danieljean

12:42 am on Dec 17, 2003 (gmt 0)

10+ Year Member



You don't need an absolute link...

I often see:
<img src="logoimages/logo.gif">

instead of:
<img src="/logoimages/logo.gif">

the initial "/" is important.

Shuvi

5:14 pm on Dec 17, 2003 (gmt 0)

10+ Year Member



Yeah that's what I used.

Gordon2004

7:59 am on Dec 18, 2003 (gmt 0)

10+ Year Member



Hey guys,

This is probably going to be the newbie question of the year but I'm really battling...

How do I specify the location of images and pages not in the current folder. It was fine when I was using one dir for my images, which was located inside my main site dir.
For example:
<img src="images/footer-logo.jpg">

But now I want to organise it better so I have some pages stored in C:\site\components, the pages in components dir have to access images in C:\site\images
How to I specify this?

jim_w

9:04 am on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I always use the full URL to the image like…

[mydomain.com...]

Of course if this is on an intranet, it may not work.

Gordon2004

9:06 am on Dec 18, 2003 (gmt 0)

10+ Year Member



Yeah, I know I could do that, but there must be a way to do it without using the actual web address?

jim_w

9:17 am on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, OK…

If your images are in the top most level folder/directory like…

[mydomain.com...]

and your page is 2 levels down like …

[mydomain.com...]

then the link should be…

../../images/myimage.gif

Reason…

The 1st ../

would take you to the folder/directoty called ‘one’ and would look for them in …

[mydomain.com...]

The 2nd ../

would take you to the root so it would look for them in …

[mydomain.com...]

IeuanJ

9:20 am on Dec 18, 2003 (gmt 0)

10+ Year Member



Linking to the current directory is easy.
<img src="image.jpg">

Linking to a subdirectory

<img src="image_directory/image.jpg">

Linking to a lower directory can be done like this

<img src="../image.jpg">

../ takes you down one layer so to go down three would be
<img src="../../../image.jpg">

linking to cousin directories is just a combination of the above really, like this

<img src="../../image_directory/image.jpg">

which takes you back two directories and then up into the cousin.

One other of the suggestions...

<img src="/image_directory/image.jpg">

Actually will sometimes not work becasue in a lot of web servers that means to look in the root of the webserver first. If you imagine that you have the following...

C:\mysite (this is your site root)
C:\mysite\image_directory

...and you link from a file in c:\mysite it would work. However if you have...

C:\mysite (this is your site root)
C:\mysite\test
C:\mysite\test\image_directory

...and try it you might find it cannot find the file.

Remeber as well that any link from the header file will be realitive to that file and not to the original calling file, that one keeps coming back to put me off time and time again with the way css is organised on our intranet servers.

- And before anyone else posts about it, yes I have mixed up style and content by using the quote UBB command instead of code to highlight the code but I really prefer thos elillte boxes :)

Gordon2004

9:34 am on Dec 18, 2003 (gmt 0)

10+ Year Member



Thanks for your help guys!

I've got it working perfectly now. Of course that's only locally... hope it still works when I finally upload it.

One last question:
I always thought it made more sense to use relative (I think they're called?) links. But now you say there coupld be problems. Would you guys suggest changing them to absolute links?

IeuanJ

10:52 am on Dec 18, 2003 (gmt 0)

10+ Year Member



I would always use relative links, that way you can transport the site as one. Imagine you coded everything as "http://www.myprovider.com/mysite/filename.ext" then you found yourself needing to move providers? Imagine the pain changing all those instances, where if you use relative links you could just pick it up and put it down wherever and it will work.

The third option is to use a base url value, this would give you one set directory for the whole site that you could use absolute addresses from. I know many who use this and swear by it and I can see why, but the only problem I have ever had with relative linking is when I have complicated folder structures (3-4 levels) and forget where I am.

jim_w

11:13 am on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>http://www.myprovider.com/mysite/filename.ext<<

Moving to a new provider should not change the domain name unless your page, not site, is on an ISP vs a hosting company.

So if you have your own domain name, don't worry about the above.

IeuanJ

11:23 am on Dec 18, 2003 (gmt 0)

10+ Year Member



That is very true, if you have your own domain you can take it with you. But then relative or base url systems would be best if you are on someplace like geocities or a uni web server.

Plus it has allowed me in the past to pull up a whole new second copy of part of the site in a test directory without having to alter any links so I can view it online and then simply dump it back in place later.

danieljean

4:38 pm on Dec 18, 2003 (gmt 0)

10+ Year Member



Like IeuanJ, I find it easier to work with pages if they don't have a domain hard coded in the image or other links.

Similarly, if you want to change something from one directory to another, say

mysite.com/widgets/blue/page.html

to

mysite.com/widgets/blue/deep_blue/page.html

you're going to have to rewrite all those image links.

So this:

<img src="image_directory/image.jpg">

should be:

<img src="/image_directory/image.jpg">

the initial "/" will always retrieve the resource from the context root.

Also, if you use "../" you are also retrieving resources relative to your current folder. (Not to mention that when I did that last year the security chief told me in no uncertain terms that this had security implications and I was NOT to do this ever again).

robert adams

5:27 pm on Dec 18, 2003 (gmt 0)

10+ Year Member



sounds like your security chief is a little paranoid. If millions of websites around the world use this without security risks, I think it would be OK.

robert
remember, just because you're paranoid, doesn't mean they are not out to get you.

jim_w

10:31 pm on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It’s a personal preference thing. I have been doing web pages since ’92 or so, and my preference is the entire URL. But it depends on a lot of factors. The HML editor you’re using, what platform the server is on, (Windows, UNIX, etc.) and probably a lot more than that when it comes to political and SE ranking issues. As long as it works, that is all that really matters. You may one to try the various ways on different pages to sample all to find your own preferences.

danieljean

11:56 pm on Dec 18, 2003 (gmt 0)

10+ Year Member



remember, just because you're paranoid, doesn't mean they are not out to get you.

Yep, and just cause they're out to get you doesn't mean you're not also paranoid ;)

IeuanJ

10:56 am on Dec 19, 2003 (gmt 0)

10+ Year Member



I think your security guy has a few broken links himself

:o)