<p>I can do something like this and it will display all featured images but will require looping through the entire image set for each entry.</p>

<pre><code>{% for image in entry.image %}
    {% if image.featured | length %}
        &lt;a href="{{ entry.url }}"&gt;&lt;img src="{{ image.getUrl('thumb') }}" alt="{{ image.title }}" class="img-fluid"&gt;&lt;/a&gt;
    {% endif %}
{% endfor %}
</code></pre>

<p>Also came up with another solution that goes through the images until it finds a featured image and then stops. If no featured image is found it displays the first one.</p>

<pre><code>{% set break = false %}
{% for image in entry.image if not break %}
    {% if image.featured | length %}
        &lt;a href="{{ entry.url }}"&gt;&lt;img src="{{ image.getUrl('thumb') }}" alt="{{ image.title }}" class="img-fluid"&gt;&lt;/a&gt;                                 
      % set break = true %}
    {% endif %}
{% endfor %}

{% for image in entry.image.limit(1) if not break %}
    &lt;a href="{{ entry.url }}"&gt;&lt;img src="{{ image.getUrl('thumb') }}" alt="{{ image.title }}" class="img-fluid"&gt;&lt;/a&gt;                                 
    {% set break = true %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2017-08-23T15:29:17.203Z
2017-08-23T16:32:35.333Z
2017-08-23T16:32:35.333Z
SoHo
<p>I have an Assets field with a set of images. What is the best way to find one image that has 'featured' checkbox checked? This is the code I put together to check which of the images is marked 'featured' but I'm not sure how to modify this so to display just the 'featured' image without looping through the entire set. In my use case I need to display a page of entries with featured image for each of them.</p>

<pre><code>{% for image in entry.image %}
   &lt;a href="{{ entry.url }}"&gt;&lt;img src="{{ image.getUrl('thumb') }}"&gt;&lt;/a&gt;
   {% if image.featured | length %}(Featured Image){% endif %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2017-08-23T11:52:23.810Z
How are you marking the image as featured?
Jalen Davenport
CC BY-SA 3.0
2017-08-23T14:40:31.990Z
@JalenDavenport There is a 'featured' checkbox associated with each image in the 'image' assets field.
SoHo
CC BY-SA 3.0
2017-08-23T15:26:19.827Z
I can do something like this (see below) and it will display all featured images but will require looping through the entire image set for each entry.
SoHo
CC BY-SA 3.0
2017-08-23T15:47:48.013Z
For my use case I would like to check if there is a "featured" image in the set first and if not, then display the first image in the set.
SoHo
<assets><elementcriteriamodel><image>
How to display a specific image from Assets field
# How to display a specific image from Assets field

(Asked by: username_0 on 2017-08-22)

I have an Assets field with a set of images. What is the best way to find one image that has 'featured' checkbox checked? This is the code I put together to check which of the images is marked 'featured' but I'm not sure how to modify this so to display just the 'featured' image without looping through the entire set. In my use case I need to display a page of entries with featured image for each of them.
{% for image in entry.image %}
   
   {% if image.featured | length %}(Featured Image){% endif %}
{% endfor %}

**Tags:** assets, elementcriteriamodel, image
> **Comments:**
> **username_1**: How are you marking the image as featured?  
> **username_0**: @JalenDavenport There is a 'featured' checkbox associated with each image in the 'image' assets field.  
> **username_0**: I can do something like this (see below) and it will display all featured images but will require looping through the entire image set for each entry.  
> **username_0**: For my use case I would like to check if there is a "featured" image in the set first and if not, then display the first image in the set.  

---

## 1 answers

### Answer by username_0 on 2017-08-23. Score: 1 | Accepted answer

I can do something like this and it will display all featured images but will require looping through the entire image set for each entry.
{% for image in entry.image %}
    {% if image.featured | length %}
        
    {% endif %}
{% endfor %}

Also came up with another solution that goes through the images until it finds a featured image and then stops. If no featured image is found it displays the first one.
{% set break = false %}
{% for image in entry.image if not break %}
    {% if image.featured | length %}
                                         
      % set break = true %}
    {% endif %}
{% endfor %}

{% for image in entry.image.limit(1) if not break %}
                                     
    {% set break = true %}
{% endfor %}


---

