문제

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) :
        $image = 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'])); ?>" />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top