【发布时间】:2011-03-01 07:29:38
【问题描述】:
我创建了一个页面内容类型,并将此代码放入其中。并将输入样式设置为 php.why 图像无法显示。我在我的本地主机上测试它。
<img src="<?php echo $bath_path; ?>/images/1.jpg">
【问题讨论】:
我创建了一个页面内容类型,并将此代码放入其中。并将输入样式设置为 php.why 图像无法显示。我在我的本地主机上测试它。
<img src="<?php echo $bath_path; ?>/images/1.jpg">
【问题讨论】:
Drupal 方式:
$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'));
【讨论】:
base_path() 将始终有效,但在某些模板中,base_path() 的返回值已存储在 $base_path 变量中(我不确定为什么,可能出于性能原因)。 print theme('image', [arguments]); 行表示您正在调用 theme() 函数并打印其输出。反过来,theme() 函数将调用theme_image([arguments]),或者如果theme_image() 已被覆盖,则将调用覆盖函数。要了解有关 Drupal 主题系统和主题覆盖的更多信息,请参阅 drupal.org/node/341628。