Using the path_to_theme() function
When we build Drupal sites we typically have a lot of custom design elements. It is important to be able to display images from the filesystem in a dynamic fashion (non-absolute paths). Should you need to move the site, you wouldn’t want to have to reset image paths everywhere. The base_path() and path_to_theme() functions do all of the dirty work for you.
1 2 |
$theme_dir = base_path() . path_to_theme(); print "<img src="{$theme_dir}/_images-base/myimg.png" alt="This is my image">"; |
You may also want to check out the $directory variable that is part of the theme system in Drupal.