How to output a placeholder image if an Assets field is empty I'm trying to output an Asset image if the Main Image field is populated, and if it's not populated, I'd like to output a placeholder image. But I'm having problems getting the conditional to work - it outputs the image in the Assets field, but when the field is empty, it's not outputting the placeholder image. Any ideas on what I'm doing wrong here? Thanks.

{% if entry.mainImage %}
  {% for asset in entry.mainImage %}
    &lt;img src="{{ asset.url }}" alt="{{ asset.title }}" /&gt;
  {% endfor %}
{% else %}
  &lt;img src="http://placehold.it/130x130/f5f5f5/ccc.png" height="130" width="130" alt="{{ entry.title }}" /&gt;
{% endif %}
Thanks to Brad for the answer, and the solution was to use {% if entry.mainImage|length %} instead of {% if entry.mainImage %} for the conditional. So my working code looked like this:

{% if entry.mainImage|length %}
  {% for asset in entry.mainImage %}
    &lt;img src="{{ asset.url }}" alt="{{ asset.title }}" /&gt;
  {% endfor %}
{% else %}
  &lt;img src="http://placehold.it/130x130/f5f5f5/ccc.png" height="130" width="130" alt="{{ entry.title }}" /&gt;
{% endif %}