<p>Your answer with a <code>for</code> loop works but if you know there's only one image associated with that field, you can simplify your code using <code>.first()</code>:</p>

<pre><code>    &lt;img src="{{ entry.author.authorImage|length ? entry.author.authorImage.first().getUrl() : '/images/userprofiledefault.jpg' }}" alt="{{ entry.author.getFullName }}"&gt;
</code></pre>

<p>Think of assets (and relationships in general) as a <a href="http://buildwithcraft.com/docs/assets-fields#templating" rel="nofollow">container</a> that can hold more than one asset (or relationship). That's why you need to tell Craft <em>which</em> one you want—even if there's only one. Your <code>for</code> loop works because it's looping through that object (technically an ElementCriteriaModel object).</p>

CC BY-SA 3.0
2015-11-07T18:00:50.240Z
Ah perfect. Thanks for that. Will swap it out for that.
Gary
CC BY-SA 3.0
2015-11-07T19:22:11.437Z
@Gary when using first you should check if it does return an asset model before accessing one of its properties!
carlcs
CC BY-SA 3.0
2015-11-07T23:04:46.490Z
Good thought carlcs, updated my answer to include a fallback image.
RitterKnight
CC BY-SA 3.0
2015-11-07T17:54:55.863Z
2015-11-07T23:04:03.933Z
2015-11-07T23:04:03.933Z
RitterKnight
<p>Ah it would of been handy if I had of entered the assets loop!</p>

<pre><code>  {% for asset in entry.author.authorImage %}
    &lt;img src="{{ asset.getUrl() }}" alt="{{ entry.author.getFullName }}"&gt;
  {% endfor %}
</code></pre>

CC BY-SA 3.0
2015-11-06T14:18:35.463Z
2015-11-06T14:18:35.463Z
Gary
<p>I have a custom field for a user which is an asset, it has the users larger profile photo.</p>

<p>In an entry template I can get their profile photo using:</p>

<pre><code>{{ entry.author.getPhotoUrl }}
</code></pre>

<p>But I want to get the custom field.</p>

<p>Something like:</p>

<pre><code>{{ entry.author.authorImage }}
</code></pre>

<p>I am sure I am missing something very simple?</p>

<users>
How can I get an entries author custom field?
# How can I get an entries author custom field?

(Asked by: username_0 on 2015-11-06)

I have a custom field for a user which is an asset, it has the users larger profile photo.
In an entry template I can get their profile photo using:
{{ entry.author.getPhotoUrl }}

But I want to get the custom field.
Something like:
{{ entry.author.authorImage }}

I am sure I am missing something very simple?

**Tags:** users

---

## 2 answers

### Answer by username_1 on 2015-11-07. Score: 1 | Accepted answer

Your answer with a for loop works but if you know there's only one image associated with that field, you can simplify your code using .first():
    

Think of assets (and relationships in general) as a container that can hold more than one asset (or relationship). That's why you need to tell Craft which one you want—even if there's only one. Your for loop works because it's looping through that object (technically an ElementCriteriaModel object).

> **Comments:**
> **username_0**: Ah perfect. Thanks for that. Will swap it out for that.  
> **username_2**: @Gary when using first you should check if it does return an asset model before accessing one of its properties!  
> **username_1**: Good thought carlcs, updated my answer to include a fallback image.  

---

### Answer by username_0 on 2015-11-06. Score: 1

Ah it would of been handy if I had of entered the assets loop!
  {% for asset in entry.author.authorImage %}
    
  {% endfor %}


---

