图像类型作为 drupal-7 中的背景

标签 image drupal drupal-7 content-type

大家好:我定义了一个新的内容类型: 标题、链接字段和图像字段。 因此,我想让该图像在显示时成为内容类型的背景。我该怎么做?

提前致谢

最佳答案

一个非常快速的方法是将自定义 node.tpl.php 添加到您的主题并执行此操作:

<?php
$url = file_create_url($node->field_image[$node->language][0]['uri']);
?>
<div style="background:url(<?php echo $url; ?>) left top no-repeat;" id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
// Rest of node.tpl.php here

关于图像类型作为 drupal-7 中的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9130997/

相关文章:

mysql - 将一个表中的两个字段与另一个表中的 id 元素相匹配的 SQL 语句

php - Drupal 模块主题 - 默认 CSS?

drupal-7 - Drupal 7 : make nodes private (for authenticated users only) visible

image - chrome中png图像中的黑色背景

javascript - 如何使每个图像的功能工作一次

jquery - 尝试通过 switch 更改 img src

MATLAB 中的图像上采样使用 image() 和 imshow() 生成白色图像

javascript - Twig 根据分辨率对元素进行分组

drupal - 如何创建在 Drupal 7 网站之间传输节点的提要?

web-services - 我们如何使用有规则的服务