How do I check for the presence of an asset before accessing an empty asset field? I have a single asset field that handles two kinds of images:

1) Big Banner image
2) Small featured image

The problem is I want to check for the presence of the second image before I output it on the page. I am doing it like so:

   {% if entry.igBanner[1] | length %}
      {% set asset = entry.igBanner[1] %}
      &lt;img src={{ asset.url }} class="img-responsive" alt={{entry.title}}&gt;
    {% endif %}


But when I try to check the length of an empty index (where the image is not ), my template crashes saying I am trying to pull a method on a null variable. How do I check the presence of an image asset at index[1]?
You could just check the length of the whole asset array first, to make sure there are two images. Something like this:

{% if (entry.igBanner | length) &gt; 1 %}
    {% set asset = entry.igBanner[1] %}
    &lt;img src={{ asset.url }} class="img-responsive" alt={{entry.title}}&gt;
{% endif %}