I'm very amateur in theming. Using Basic theme for Drupal 6, I try to add an image to the very top of the page. (Something like repeating flags here) However, when I add

<img src="images/flags.png"/>

to the upper side of page.tpl.php, the image has proper permissions but does not show up. No surprise though since the image is hyperlinked as


I have also tried defining a div class="flags" at the top of page.tpl.php and then introduce the image as the div's background-image url('images/flags.png'). No success either.

Direct insertion of static images used to work on my other theme. So got really perplexed and appreciate your help.

  • 1
    Where is the image saved? You need to create an absolute path to the image.
    – sheena_d
    Commented Jul 31, 2012 at 15:02

2 Answers 2


Put all your theme images in a directory in your theme; let's call it img.

Then you can load them like so:

<img src="<?php echo drupal_get_path('theme', 'THEME_NAME'); ?>/img/flags.png">

Hope this helps.

(More info at drupal_get_path();)

  • It worked Thanks! However I still can not theme it. I'v added class="flags" into image tag and defined the class in default.css as .flags{background-repeat:repeat-x;}. However the image does not repeat. Any ideas?
    – alfish
    Commented Jul 31, 2012 at 15:20
  • That's not how img elements work. Set the background to a block element (i.e., a <div> using CSS. If you have a .css file in your theme, you just have to do .flags{background: url('img/flags.png') repeat-x;}
    – aendra
    Commented Jul 31, 2012 at 15:37
  • Strangely, enclosing the image in a <div class="flags"... and then adding background: url('img/flags.png') repeat-x;} to layout.css did not work. So my workaround was to directly add width="100%" inside the <img> tag and use a wider image instead. I know it is not ideal, though. any ideas?
    – alfish
    Commented Jul 31, 2012 at 16:38
  • Are you using Firebug or Google Chrome? It'd it'd help a lot if you're able to identify whether that declaration in layout.css is even visible to the div in question. Also, if at first you don't succeed -- try clearing the cache.
    – aendra
    Commented Jul 31, 2012 at 16:43

I think you should use the div header and css background image to put that kind of image. Anyway if you want to put a static image in the theme you can add

<img src="<?php print $GLOBALS['base_url'];?>/images/flag.png" />

$GLOBALS['base_url'] is the url of the website (http://www.example.com or http://www.example.com/folder if it's in a subfolder)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.