【问题标题】:drupal image pathdrupal图像路径
【发布时间】:2011-03-01 07:29:38
【问题描述】:

我创建了一个页面内容类型,并将此代码放入其中。并将输入样式设置为 php.why 图像无法显示。我在我的本地主机上测试它。

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

【问题讨论】:

    标签: drupal drupal-6


    【解决方案1】:

    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'));
    

    【讨论】:

    • thank you.got it.but 我仍然不知道什么时候应该使用 base_path(),什么时候应该使用 $base_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
    猜你喜欢
    • 2011-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多