Displaying a field image with an image style in node.tpl.php in Drupal 7


<?php
      $image_uri 
$node->field_image['und'][0]['file']['uri'];
      
$image_url_with_style image_style_url('square_thumbnail',$image_uri);
      echo 
'<img src="'.$image_url_with_style.'">';
?>
If your field type is "Multimedia asset" (from the Media Module) instead of the built in "Image" type you need to use the object syntax:
<?php
      $image_uri 
$node->field_image_media['und'][0]['file']->uri;
      
$image_url_with_style image_style_url('square_thumbnail',$image_uri);
      echo 
'<img src="'.$image_url_with_style.'">';
?>
© 2011 Adam Gerson.