开发者

Getting the field_image path in Drupal 7

In Drupal 6, I would do the following to get images in my node--articles.tpl.php page:

<?php
$cck_images = $node->field_image;

if (count($cck_images)>0) :
    foreach ($cck_images as $cck_image) :
        $ima开发者_Python百科ge = theme('imagecache', 'large', $cck_image['filepath'], $cck_image['data']['alt'], $cck_image['data']['title']);
        print $image;
    endforeach;
endif;
?>

However, in Drupal 7 there is not a '['filepath']', I have tried using:

<?php print_r($field_image); ?>

But the variable is not there. I know Drupal 7 is still in alpha, but any help would be greatly appreciated!


Try this:

<?php
$nid = 4; 
$node = node_load($nid);
?>
<img src="<?php echo render(file_create_url($node->field_image['und'][0]['uri'])); ?>" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜