<p>It works very simply. Note that the photo field is an <strong>asset object</strong>, not an array of asset objects.</p>
<pre><code>{% for user in block.staffList.all() %}
   Image URL: {{ user.photo.getUrl() }}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2020-09-27T17:53:34.890Z
That's the ticket, thanks! Just a quick note: to skip over people that don't have photos, you can use `{% if member.photo is not null %}`
Bryce
CC BY-SA 4.0
2020-09-28T07:29:28.150Z
@Bryce Of course, you can still do eager loading and caching 
**{% for user in block.staffList.with(['photo']).all() %}** . I gave a short answer, Craft CMS has many methods to optimize.
Pavel Pavlovich
CC BY-SA 4.0
2020-09-26T16:15:34.343Z
2020-09-26T16:15:34.343Z
Pavel Pavlovich
<p>I'm making a staff page with a User field type, so you select all the users you want displayed. I'm having trouble showing each user's photo though. This works:</p>
<pre><code>{% for user in block.staffList.all() %}
   Image URL: {{ craft.assets.id(user.photoId).one().url }}
{% endfor %}
</code></pre>
<p>But seems far from the ideal solution. Is there a more graceful way to do this?</p>

CC BY-SA 4.0
2020-09-25T20:54:17.413Z
Ok, this works: `{{ user.photoUrl(user.id) }}`, but still seems a little redundant
Bryce
<users>
Display user photo within a User field type
# Display user photo within a User field type

(Asked by: username_0 on 2020-09-25)

I'm making a staff page with a User field type, so you select all the users you want displayed. I'm having trouble showing each user's photo though. This works:
{% for user in block.staffList.all() %}
   Image URL: {{ craft.assets.id(user.photoId).one().url }}
{% endfor %}

But seems far from the ideal solution. Is there a more graceful way to do this?

**Tags:** users

> **Comments:**
> **username_0**: Ok, this works: `{{ user.photoUrl(user.id) }}`, but still seems a little redundant  

---

## 1 answers

### Answer by username_1 on 2020-09-26. Score: 2 | Accepted answer

It works very simply. Note that the photo field is an asset object, not an array of asset objects.
{% for user in block.staffList.all() %}
   Image URL: {{ user.photo.getUrl() }}
{% endfor %}

> **Comments:**
> **username_0**: That's the ticket, thanks! Just a quick note: to skip over people that don't have photos, you can use `{% if member.photo is not null %}`  
> **username_1**: @username_0 Of course, you can still do eager loading and caching  **{% for user in block.staffList.with(['photo']).all() %}** . I gave a short answer, Craft CMS has many methods to optimize.  

---

