Get taxonomy term field value? I have some taxonomy terms that have an image field in them. I am trying to get the value of the image field in my templates. How can I do this? The field's name is field_header_image.

I have this so far but it does not work..

$headerimg = field_view_field('taxonomy_term', $term, 'field_header_image'); 
print render($headerimg);


I'm guessing I need something else for taxonomy_term but I'm not sure what that should be.
You can get it like this :

$term = taxonomy_term_load($tid);
$field_header_image = field_get_items('taxonomy_term', $term, 'field_header_image');
if ($field_header_image) {
  $headerimg = field_view_value('taxonomy_term', $term, 'field_header_image', $field_header_image[0], array('type' =&gt; 'image'));
}
print render($headerimg);


If you want to use an image_style :

$headerimg = field_view_value('taxonomy_term', $term, 'field_header_image', $field_header_image[0], array(
  'type' =&gt; 'image',
  'settings' =&gt; array(
    'image_style' =&gt; 'my_image_style', //place your image style here
  ),
));


Here is a contextual answer if you are on your taxonomy term page.

In your file template.php use the theme_preprocess_page function like this :

function mytheme_preprocess_page(&amp;$vars) {
  $term = menu_get_object('taxonomy_term', 2);
  if ($term) {
    $field_header_image = field_get_items('taxonomy_term', $term, 'field_header_image');
    if ($field_header_image) {
      $vars['headerimg'] = field_view_value('taxonomy_term', $term, 'field_header_image', $field_header_image[0], array('type' =&gt; 'image'));
    }
  }
}


Then in you page.tpl.php you can print render($headerimg);