<p>You're close!</p>

<pre><code>{% set numberOfPhotos = entry.photos|length %}

{% if numberOfPhotos &gt; 1 %}
  {# more than one #}
{% elseif numberOfPhotos == 1 %}
  {# exactly one #}
{% else %}
  {# no photos (always handle this case...) #}
{% endif %}
</code></pre>

CC BY-SA 3.0
2015-01-17T20:30:06.050Z
Thank you very much, Marion! This was a huge help. I almost had things working using a {{ loop.index }} conditional but yours works much better. Thanks again! Greatly appreciate the advice.
glider
CC BY-SA 3.0
2015-01-17T19:10:55.843Z
2015-01-17T19:10:55.843Z
Marion Newlevant
<p>I have a simple question about Assets. I want to output some HTML around a set of image IF there is more than one image. If there is just one image I would output different HTML. I know how to do this easily within EE's Assets but not sure how to do it in Craft's Assets. </p>

<p>In EE I would use something like:</p>

<pre><code>{if photo:total_files &gt; "1"} &lt;!-- if there is more than one photo show a slideshow --&gt;
&lt;ul class="slider"&gt;
    &lt;img scr=""&gt;
&lt;/ul&gt;

{if:else} &lt;!-- if its just one photo show it... --&gt;
    &lt;img scr="" class="single"&gt;
{/if}
</code></pre>

<p>I think I could target the first image but not sure how to construct the full conditional.</p>

<pre><code>{% if entry.photos | length %}

{% set image = entry.assetFieldHandle.first() %}
&lt;img src="{{ image.getUrl() }}" width="{{ image.getWidth() }}" height="{{ image.getHeight() }}"&gt;

{% endif %}
</code></pre>

<assets>
Assets count conditional
# Assets count conditional

(Asked by: username_0 on 2015-01-17)

I have a simple question about Assets. I want to output some HTML around a set of image IF there is more than one image. If there is just one image I would output different HTML. I know how to do this easily within EE's Assets but not sure how to do it in Craft's Assets. 
In EE I would use something like:
{if photo:total_files > "1"} 

    


{if:else} 
    
{/if}

I think I could target the first image but not sure how to construct the full conditional.
{% if entry.photos | length %}

{% set image = entry.assetFieldHandle.first() %}


{% endif %}

**Tags:** assets

---

## 1 answers

### Answer by username_1 on 2015-01-17. Score: 8 | Accepted answer

You're close!
{% set numberOfPhotos = entry.photos|length %}

{% if numberOfPhotos > 1 %}
  {# more than one #}
{% elseif numberOfPhotos == 1 %}
  {# exactly one #}
{% else %}
  {# no photos (always handle this case...) #}
{% endif %}

> **Comments:**
> **username_0**: Thank you very much, Marion! This was a huge help. I almost had things working using a {{ loop.index }} conditional but yours works much better. Thanks again! Greatly appreciate the advice.  

---

