大家好:我定义了一个新的内容类型: 标题、链接字段和图像字段。 因此,我想让该图像在显示时成为内容类型的背景。我该怎么做?
提前致谢
最佳答案
一个非常快速的方法是将自定义 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/