在Drupal 6中,我会执行以下操作来获取节点中的图像 - articles.tpl.php页面:
<?php
$cck_images = $node->field_image;
if (count($cck_images)>0) :
foreach ($cck_images as $cck_image) :
$image = theme('imagecache', 'large', $cck_image['filepath'], $cck_image['data']['alt'], $cck_image['data']['title']);
print $image;
endforeach;
endif;
?>
然而,在Drupal 7中没有'['filepath']',我尝试过使用:
<?php print_r($field_image); ?>
但变量不存在。我知道Drupal 7仍处于alpha状态,但任何帮助都会非常感激!
答案 0 :(得分:9)
试试这个:
<?php
$nid = 4;
$node = node_load($nid);
?>
<img src="<?php echo render(file_create_url($node->field_image['und'][0]['uri'])); ?>" />