Hey up

I have an image on my front page at:

http://dakuhnm2.burngreave.net/drupalcoho/DrupalCohousingFromWork

and images are kept in the files folder, with the above being the root for the site. So the absolute address is e.g.:

http://dakuhnm2.burngreave.net/drupalcoho/DrupalCohousingFromWork/files/...

It's img src="files/img.jpg" - and that's fine on the front page, except when someone views it as a node, it disappears. This happens because the browser then tries to find the img in node/x/files.

But no method seems to work - except using an absolute path, and I don't want to do that, for the obvious reason that the above is the development location and I'll be changing it shortly to the live site name. That would mean changing every path.

src = "/files/img.jpg" should work, but doesn't for either. src = "../files/img.jpg" only works for the node, coz it goes up to the parent.

What am I missing???

Dan

Comments

danaktivix’s picture

The img links all work if I turn off clean URLs. What's that all about then?

Anyone?

MasterSolution’s picture

It works when you turn off Clean URLs because then it's the same path on the frontpage and on any other node page because it loads from the frontpage (?q=blabla).

The best way to do it is by specifying the absolute path, but taking that variable from Drupal, so that you can easily change it when you switch hosts.

<img src="<?php echo base_path() ?>files/img.jpg" />

Martin
Web Solutions