<p>When you reference a relationship field (ie: Entries field, Assets field, etc), you will automatically get an <strong>ElementCriteriaModel</strong> to represent the "value" of that field.</p>

<p>Since <code>entry.image</code> is giving you an ElementCriteriaModel, you need to specify exactly what you want that ECM to do. If you try to use the ECM without specifying <code>.first</code> (or <code>.last</code>, or <code>.total</code>), then by default it will <em>assume</em> you meant <code>.find</code>. Which is obviously not what you're trying to do in this case.</p>

<p>I highly recommend reading my answer on <a href="https://craftcms.stackexchange.com/a/16070/45">this other thread...</a> It's not quite a duplicate of your question, but it covers a lot of the same ground.</p>

CC BY-SA 3.0
2017-02-09T21:02:49.783Z
Ah OK, that's making more sense, and thank you for the link to your other answer. So when creating fields for a section, is every 'asset' field a 'relationship' field? I know as a field 'entries' would be, but I didn't realize the same would be true for images/assets. Does that then imply the other fields, like 'plain text' and 'light switch' are **not** relationships? Follow-up Q: Of all the possible fields to associate with a section, which are which? Thank you!
Nathan D Huening
CC BY-SA 3.0
2017-02-09T21:30:54.850Z
Relationship fields are any fields based on _elements_... I'd recommend reading up on [Element Types](https://craftcms.com/docs/templating/elementcriteriamodel#creating-an-elementCriteriaModel), as they're a pretty crucial part of the Craft ecosystem.
Lindsey D
CC BY-SA 3.0
2017-02-09T05:27:47.017Z
2017-02-09T05:27:47.017Z
2017-04-13T12:51:00.253Z
Lindsey D
<p>So this may be a stupid question, but I've sort of never wrapped my head around it. When fetching an image from an entry -- even if there's only one associated with the field -- you can't just do:</p>

<pre><code>{% set image = entry.image %}
</code></pre>

<p>You have to say:</p>

<pre><code>{% set image = entry.image.first() %}
</code></pre>

<p>Which implies that the returned data are an object or array, and that the actual desired image is the "first" item in it. My questions are:</p>

<ol>
<li>Why is it structured this way?</li>
<li>Which other properties are in the <code>entry.image</code> apart from the actual resource itself? What would you use those for?</li>
</ol>

<p>I realize this may be obvious to pro Craft developers, but I remember the first Craft site I ever built, I had a devil of a time trying to remember that!</p>

<templating><entry><image>
What other properties are in the "entry.image" object?
# What other properties are in the "entry.image" object?

(Asked by: username_0 on 2017-02-09)

So this may be a stupid question, but I've sort of never wrapped my head around it. When fetching an image from an entry -- even if there's only one associated with the field -- you can't just do:
{% set image = entry.image %}

You have to say:
{% set image = entry.image.first() %}

Which implies that the returned data are an object or array, and that the actual desired image is the "first" item in it. My questions are:

Why is it structured this way?
Which other properties are in the entry.image apart from the actual resource itself? What would you use those for?

I realize this may be obvious to pro Craft developers, but I remember the first Craft site I ever built, I had a devil of a time trying to remember that!

**Tags:** templating, entry, image


---

## 1 answers

### Answer by username_1 on 2017-02-09. Score: 1 | Accepted answer

When you reference a relationship field (ie: Entries field, Assets field, etc), you will automatically get an **ElementCriteriaModel** to represent the "value" of that field.

Since `entry.image` is giving you an ElementCriteriaModel, you need to specify exactly what you want that ECM to do. If you try to use the ECM without specifying `.first` (or `.last`, or `.total`), then by default it will *assume* you meant `.find`. Which is obviously not what you're trying to do in this case.

I highly recommend reading my answer on [this other thread...](https://craftcms.stackexchange.com/a/16070/45) It's not quite a duplicate of your question, but it covers a lot of the same ground.

> **Comments:**
> **username_0**: Ah OK, that's making more sense, and thank you for the link to your other answer. So when creating fields for a section, is every 'asset' field a 'relationship' field? I know as a field 'entries' would be, but I didn't realize the same would be true for images/assets. Does that then imply the other fields, like 'plain text' and 'light switch' are **not** relationships? Follow-up Q: Of all the possible fields to associate with a section, which are which? Thank you!  
> **username_1**: Relationship fields are any fields based on _elements_... I'd recommend reading up on [Element Types](https://craftcms.com/docs/templating/elementcriteriamodel#creating-an-elementCriteriaModel), as they're a pretty crucial part of the Craft ecosystem.  

---

