<p>You could try something like:</p>

<pre><code>{% for entry in entries %}
  {% for image in entry.portfolio.orderBy('RAND()').limit(8)
    &lt;img src="{{ image.getUrl() }}"&gt;
  {% endfor %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-05-29T12:19:31.637Z
2015-05-29T12:19:31.637Z
Alec Ritson
<p>Im looking up the last 2 entries like this</p>

<pre><code>{% set entries = craft.entries.section('report').limit(2) %}
</code></pre>

<p>My entry got an assets field called 'portfolio'. I would like to retrieve 8 images in random order. How would I do this?</p>

<templating><entries><forloop>
retrieve assets from an entries
# retrieve assets from an entries

(Asked by: username_0 on 2015-05-29)

Im looking up the last 2 entries like this
{% set entries = craft.entries.section('report').limit(2) %}

My entry got an assets field called 'portfolio'. I would like to retrieve 8 images in random order. How would I do this?

**Tags:** templating, entries, forloop

---

## 1 answers

### Answer by username_1 on 2015-05-29. Score: 2 | Accepted answer

You could try something like:
{% for entry in entries %}
  {% for image in entry.portfolio.orderBy('RAND()').limit(8)
    
  {% endfor %}
{% endfor %}


---

