<p>You can do</p>

<pre><code> {% image = craft.assets.id(x).first() %}
</code></pre>

<p>Where x is the ID of your element. You can see the ids of your elements in your cp. There is a little wheel icon below your asset sources where you can define which attributes to display. Just check the selectbox for id</p>

<p>You can learn more about fetching entries with <code>ElementCriteriaModels</code> in the <a href="https://craftcms.com/docs/templating/elementcriteriamodel#parameter-value-syntax" rel="nofollow noreferrer">docs</a></p>

<p>Your problem was: you did not fetch the element. You prepared your database query but you need to execute it with <code>first()</code> or <code>find()</code> because</p>

CC BY-SA 3.0
2018-01-17T18:50:22.920Z
I was just about to update this post saying that I figured out the solution with this very same method. Glad to know I did it right. Thanks!
Morgan
CC BY-SA 4.0
2020-02-07T22:28:29.123Z
2020, `.first()` is deprecated for `.one()`
aaandre
CC BY-SA 3.0
2018-01-17T17:35:21.723Z
2018-01-17T17:35:21.723Z
Robin Schambach
<p>I'm trying to grab a specific image to display that is located in assets. I tried using <code>{% set image = craft.assets.filename('image_filename.jpg') %}</code> but I get the error "An unknown image object was used." I also tried referring to one of the asset sources which I saw as a solution in another post related to my question: <code>{% set image = craft.assets.source('my_images') %}</code> but I'm not sure how that would help me grab a specific image. <code>{% set image = craft.assets.images[0] %}</code> just grabs an image from any of the asset sources if I change the index number. What am I doing wrong here?? Thanks in advance!  </p>

<templating><assets><image>
Display a specific image from assets
# Display a specific image from assets

(Asked by: username_0 on 2018-01-17)

I'm trying to grab a specific image to display that is located in assets. I tried using `{% set image = craft.assets.filename('image_filename.jpg') %}` but I get the error "An unknown image object was used." I also tried referring to one of the asset sources which I saw as a solution in another post related to my question: `{% set image = craft.assets.source('my_images') %}` but I'm not sure how that would help me grab a specific image. `{% set image = craft.assets.images[0] %}` just grabs an image from any of the asset sources if I change the index number. What am I doing wrong here?? Thanks in advance!

**Tags:** templating, assets, image

---

## 1 answers

### Answer by username_1 on 2018-01-17. Score: 2 | Accepted answer

You can do
 {% image = craft.assets.id(x).first() %}

Where x is the ID of your element. You can see the ids of your elements in your cp. There is a little wheel icon below your asset sources where you can define which attributes to display. Just check the selectbox for id
You can learn more about fetching entries with ElementCriteriaModels in the docs
Your problem was: you did not fetch the element. You prepared your database query but you need to execute it with first() or find() because

> **Comments:**
> **username_0**: I was just about to update this post saying that I figured out the solution with this very same method. Glad to know I did it right. Thanks!  
> **username_2**: 2020, `.first()` is deprecated for `.one()`  

---

