Accessing field values in node--mycustomtype.tpl.php I have a content type that contains a field called headshot. This is a file field. In my custom node template file, I need to access the value of the headshot's filename property. dpr($content) produces this for the field:

[field_headshot] =&gt; Array
                        (
                            [und] =&gt; Array
                                (
                                    [0] =&gt; Array
                                        (
                                            [fid] =&gt; 53
                                            [display] =&gt; 1
                                            [description] =&gt; 
                                            [uid] =&gt; 10
                                            [filename] =&gt; kanderson.jpg
                                            [uri] =&gt; public://headshot/kanderson.jpg
                                            [filemime] =&gt; image/jpeg
                                            [filesize] =&gt; 21669
                                            [status] =&gt; 1
                                            [timestamp] =&gt; 1337356962
                                            [type] =&gt; image
                                            [rdf_mapping] =&gt; Array
                                                (
                                                )

                                            [image_dimensions] =&gt; Array
                                                (
                                                    [width] =&gt; 180
                                                    [height] =&gt; 252
                                                )

                                        )

                                )

                        )


I've tried 

&lt;img class="speaker_headshot" src="sites/default/files/styles/large/public/headshot/&lt;?php print render($content['field_headshot'][0]['filename']); ?&gt;" alt="&lt;?php print $title; ?&gt;" /&gt;


and 

&lt;img class="speaker_headshot" src="sites/default/files/styles/large/public/headshot/&lt;?php print render($content['field_headshot']['filename']); ?&gt;" alt="&lt;?php print $title; ?&gt;" /&gt;


with no success. How do I access this property?
To get a web-accessible URL for the file you need to use file_create_url() on the field's uri property. You can also make use of theme_image() so you don't have to write the HTML yourself:

$vars = array(
  'path' =&gt; file_create_url($content['field_headshot'][LANGUAGE_NONE][0]['uri']),
  'alt' =&gt; $title,
  'attributes' =&gt; array(
    'class' =&gt; array('speaker_headshot')
  )
);

$img = theme('image', $vars);

print $img;


Since this code will clutter up your template file you might want to consider putting in a preprocess function instead, something like:

function MYTHEME_preprocess_node(&amp;$vars) {
  if ($vars['node']-&gt;type == 'headshot') {
    $items = field_get_items('node', $vars['node'], 'field_headshot');
    $image = array_shift($items);

    $image_vars = array(
      'path' =&gt; file_create_url($image['uri']),
      'alt' =&gt; $vars['title'],
      'attributes' =&gt; array(
        'class' =&gt; array('speaker_headshot')
      )
    );

    $vars['image'] = theme('image', $image_vars);
  }
}


Then in your template file you can just print $image; to get the HTML output.