<p>Something like this should do it:</p>

<pre><code>{% set heroImage = entry.heroImage.one().getUrl() %}
</code></pre>

<p>Although this probably works as well:</p>

<pre><code>{% set heroImage = entry.heroImage.one().url %}
</code></pre>

<p>In Craft 3, <code>.first()</code> has been replaced with <code>.one()</code>.  <a href="https://docs.craftcms.com/v3/changes-in-craft-3.html#query-methods" rel="nofollow noreferrer">https://docs.craftcms.com/v3/changes-in-craft-3.html#query-methods</a></p>

CC BY-SA 4.0
2017-08-30T21:53:08.857Z
2018-11-02T18:41:26.557Z
2018-11-02T18:41:26.557Z
Brad Bell
<p>I am having a problem getting image urls from Craft 3. I understand that there is a new syntax but I cannot find the syntax to use. The craft 2 version of what I am trying to accomplish is</p>

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

<p>How do I achieve this in Craft 3?</p>

<templating><craft3>
Craft 3 Template - Getting Image URLs
# Craft 3 Template - Getting Image URLs

(Asked by: username_0 on 2017-08-30)

I am having a problem getting image urls from Craft 3. I understand that there is a new syntax but I cannot find the syntax to use. The craft 2 version of what I am trying to accomplish is
{% set heroImage = entry.heroImage.first().url %}

How do I achieve this in Craft 3?

**Tags:** templating, craft3

---

## 1 answers

### Answer by username_1 on 2017-08-30. Score: 4 | Accepted answer

Something like this should do it:
{% set heroImage = entry.heroImage.one().getUrl() %}

Although this probably works as well:
{% set heroImage = entry.heroImage.one().url %}

In Craft 3, .first() has been replaced with .one().  https://docs.craftcms.com/v3/changes-in-craft-3.html#query-methods


---

