Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-23T15:29:17.203Z
Answers.LastActivityDate: 2017-08-23T16:32:35.333Z
Answers.LastEditDate: 2017-08-23T16:32:35.333Z
Answers.UserDisplayName: SoHo
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-23T11:52:23.810Z
Comments.Text: How are you marking the image as featured?
Comments.UserDisplayName: Jalen Davenport
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-23T14:40:31.990Z
Comments.Text: @JalenDavenport There is a 'featured' checkbox associated with each image in the 'image' assets field.
Comments.UserDisplayName: SoHo
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-23T15:26:19.827Z
Comments.Text: 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.
Comments.UserDisplayName: SoHo
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-23T15:47:48.013Z
Comments.Text: 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.
Comments.UserDisplayName: SoHo
Tags: <assets><elementcriteriamodel><image>
Title: How to display a specific image from Assets field
ThreadText: # 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 %}
     <a href="{{ entry.url }}"><img src="{{ image.getUrl('thumb') }}"></a>
     {% 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**: @username_1 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 %}
          <a href="{{ entry.url }}"><img src="{{ image.getUrl('thumb') }}" alt="{{ image.title }}" class="img-fluid"></a>
      {% 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 %}
          <a href="{{ entry.url }}"><img src="{{ image.getUrl('thumb') }}" alt="{{ image.title }}" class="img-fluid"></a>                                 
        % set break = true %}
      {% endif %}
  {% endfor %}
  
  {% for image in entry.image.limit(1) if not break %}
      <a href="{{ entry.url }}"><img src="{{ image.getUrl('thumb') }}" alt="{{ image.title }}" class="img-fluid"></a>                                 
      {% set break = true %}
  {% endfor %}
  
  ```
  
  
  ---
  
  