i have theme it is name (car) and have image links in page.tpl.php and i want to display this image with short way anyone can help me..the most of this ways to node.tpl.php but i need to display images with page.tpl.php
<img src="rightgallery/img/img1_thumb.jpg" alt="motherly" />
i try to add this code in template.php file
// helper variable path to theme
function car_preprocess_page(&$vars) {
$vars['thefullpath'] = $GLOBALS['base_url'] . "/" . $GLOBALS['theme_path'];
}
and then print the path like this but still didnt work
<img src="<?php print $thefullpath; ?>rightgallery/img/img1_thumb.jpg" alt="motherly"
>
Actually there are 2 ways to do so directly from your theme's page.tpl.php (without the need to create a template preprocess function):
1- Using <img>
tag:
global $base_path;
print "<img src='" . $base_path . path_to_theme() . "/img/img5.jpg' width='240' height='300' />";
2- Using Drupal's theme()
:
print theme("image", array(
'path' => path_to_theme() . "'/img/img5.jpg",
'width' => "240",
'height' => "300",
));
References: