Drupal - render or print image in a drupal 7 node.tpl?

<?php print render($content['field_image']); ?>

If you want to change how the image is displayed (dimensions, link, etc), set them in Manage Display tab in the node type settings.

You can also do an imagecache preset like this:

<?php
print theme('image_style', array('path' => $node->field_image[LANGUAGE_NONE][0]['uri'], 'style_name' => [STYLE NAME]));
?>

But that's not the recommended way!

if you want to build URL from URI,

<img src="<?php print file_create_url($node->field_image[LANGUAGE_NONE][0]['uri']); ?>" />

For those using the file_entity module (perhaps with the media module), you may be wondering how to programmatically render files/images:

$image = (object) $node->field_image[ LANGUAGE_NONE ][0];
$image_entity = file_view($image, "summary");
echo drupal_render($image_entity);

Where "field_image" is your field name, and "summary" is your view mode.

Tags:

Media

Theming

7