Count items in nested field array for if/then in template I'm sure I'm missing something very straightforward here:  I want to prevent the thumbnail slider in my image gallery from being rendered if there's only one image for the node. My first thought was, optimistically:

  &lt;?php if (count($content['field_media']) &gt; 1): ?&gt;
    &lt;div id="carousel" class="flexslider clearfix"&gt;
      &lt;div class="slides"&gt;
        &lt;?php print render($content['carousel']); ?&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;?php endif; ?&gt;


I saw why that didn't work when I examined the node structure. In an example case for a node with one image, I have

 field_media (Array, 1 element)
    und (Array, 1 element)
        0 (Array, 17 elements)  


the last one being the actual file element with an fid, etc. The corresponding field for a node with two images is 

 field_media (Array, 1 element)
    und (Array, 2 elements)
        0 (Array, 17 elements)
        1 (Array, 17 elements) 


So the array I need to count is nested inside the 'und' array. I know I've used that in other templates, like $field_external_link['und'][0]['url'].  But when I print count($content['field_media']['und']), I get 0.  How do I evaluate the number of elements in that array?
You can use field_get_items api function to read values.

&lt;?php

$images = field_get_items('node', $node, 'field_media');
if (count($images) &gt; 1) {
  // Print Carousel
}
?&gt;