<p>The asset volume needs to have public urls enabled. Thanks seb.</p>

CC BY-SA 4.0
2019-11-28T10:17:16.143Z
2019-11-28T10:17:16.143Z
Niko
<p>I have an image in a matrix-field, but can't get the url from it.
<code>dump(block.image.one().url)</code> says <code>NULL</code>. My code is: </p>

<pre><code>{% if entry.hero %}
  {% for block in entry.hero %}
    {% if block.type == 'hero' %}
      {% set heroImage = block.image.one() %}
      &lt;div class="cell hero center padding-1" style="background-image: url({{ heroImage.url }});"&gt;
      &lt;/div&gt;
    {% endif %}
  {% endfor %}
{% endif %}
</code></pre>

<p><code>image.one()</code> or <code>image.first()</code>, as well as <code>.url</code> or <code>.getUrl()</code> doesn't work the same.</p>

<p>What works though is <code>{{ block.image.one().folderPath }}{{ block.image.one().filename }}</code></p>

<p>Does anyone know why? I'm on Craft CMS 3.3.15</p>

CC BY-SA 4.0
2019-11-28T09:37:27.620Z
Does the volume where your asset is have public urls enabled?
Seb
CC BY-SA 4.0
2019-11-28T10:16:26.410Z
That's it, thanks!
Niko
<templating><assets>
How to get image url from matrix field
# How to get image url from matrix field

(Asked by: username_0 on 2019-11-28)

I have an image in a matrix-field, but can't get the url from it.
dump(block.image.one().url) says NULL. My code is: 
{% if entry.hero %}
  {% for block in entry.hero %}
    {% if block.type == 'hero' %}
      {% set heroImage = block.image.one() %}
      
      
    {% endif %}
  {% endfor %}
{% endif %}

image.one() or image.first(), as well as .url or .getUrl() doesn't work the same.
What works though is {{ block.image.one().folderPath }}{{ block.image.one().filename }}
Does anyone know why? I'm on Craft CMS 3.3.15

**Tags:** templating, assets

> **Comments:**
> **username_1**: Does the volume where your asset is have public urls enabled?  
> **username_0**: That's it, thanks!  

---

## 1 answers

### Answer by username_0 on 2019-11-28. Score: 4

The asset volume needs to have public urls enabled. Thanks seb.


---

