drupal_get_path() not working in subdirectories of my site So I'm using drupal_get_path() within a block to reference an image in my themes//images directory.

And this works. At the root and all first level pages. example.com, example.com/about, etc.

However, if I am on a page such as example.com/about/csa:

Instead of continuing to output the filepath as /sites/all/... it outputs the file as //sites/all/...

This only happens when I'm in a subdirectory of the site.

Does anyone know why this might happen?

EDIT:

&lt;?php $src = drupal_get_path('theme', $GLOBALS['theme']) . '/images/carrots.png'; 
echo '&lt;img src=' . $src . ' alt="carrot background image" &gt;'
?&gt;
Its because drupal_get_path returns relative path.

Try this:

&lt;?php 
  global $base_path;
  $src = $base_path . drupal_get_path('theme', $GLOBALS['theme']) . '/imag/carrots.png'; 
  echo '&lt;img src=' . $src . ' alt="carrot background image" &gt;'
?&gt;


Edit with url function:

&lt;?php 
  $src = url(drupal_get_path('theme', $GLOBALS['theme']) . '/imag/carrots.png'); 
  echo '&lt;img src=' . $src . ' alt="carrot background image" &gt;'
?&gt;