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 %}
<img src="{{ asset.url }}" alt="{{ asset.title }}" />
{% endfor %}
{% else %}
<img src="http://placehold.it/130x130/f5f5f5/ccc.png" height="130" width="130" alt="{{ entry.title }}" />
{% endif %}
{% if entry.mainImage|length %}