drupal image path

2019-06-14 10:05发布

问题:

i created a page content type, and put this code in it. and set the input style to php.why the image can't show. i test it on my localhost.

       <img src="<?php echo $bath_path; ?>/images/1.jpg">

回答1:

Drupal way:

$path2file = base_path().'/images/1.jpg'; // If image located in {drupal root}/images. If image located in files directory, use file_directory_path() to get this path
print theme('image', $path_to_file, t('Image altername name'), t('Image title'));