By artcoder on
I just discovered that I can not use relative image paths in page.tpl.php as in ...
<div><img src="images/panelleftcorner.gif" /></div>
What is the proper way to reference images located in the themes directory? Is there a PHP variable that give me this path?
Comments
for something like that,
for something like that, wouldn't you reference the image in the .css file ?
Yes, I could. But what if
Yes, I could. But what if it was an clickable image such as ...
Or what if I wanted the image to be a spacer image to prop up some div or table cells.
In both cases, I would need the image to be a
tag rather than an css background image.
artcoder
your right
Except that using spacer images is not really the done thing in these enlightened times :)
Anyway - to reference your paths you should ideally use the url function - so you end up with something like
Hope that helps ...
mike
Like books? Check out booktribes the new (Drupal based) community for book lovers
from Computerminds
Mike,
Computerminds offer Drupal development, consulting and training
even better
if you want to develop a theme, read the theme developers guide, the phptemplate guide
When coding in paths to images used by your theme, you'll want
<img src="<?php print url($directory) ?>/images/thing.gif" />this will produe the correct path to wherever you are building your theme ... and be portable as well. You do NOT want to reference images with hard-coded paths.
For that matter, you do not want to use 'spacer.gif' unless your target audience is browsers older than 4 years. It sorta gives your code a turn-of-the-century look.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thanks
Yep. Works great. The url function was what I needed.
artcoder