<p>during this process : 
<code>{% set image = block.image.one() %}</code>
please make sure the name of handle of image is image. 
For example in this matrix the type is 'image' but to get image url you should call it. item.imageAssets.one().url
<a href="https://i.sstatic.net/bew2V.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bew2V.png" alt="Matrix"></a></p>

CC BY-SA 4.0
2020-03-24T07:27:27.390Z
2020-03-24T07:27:27.390Z
aodihis
<p>Try checking for |length</p>

<pre><code>         {% if image|length %}
          {{ image.url }}
         {% endif %}
</code></pre>

CC BY-SA 4.0
2020-02-23T07:46:35.870Z
Still. Other parameters of the image are printed like id or title but not the url.
analog junkie
CC BY-SA 4.0
2020-02-22T12:25:38.003Z
2020-02-22T12:25:38.003Z
CreateSean
<p>block.image is actually an array (even if only 1 image in it) therefore you need to loop over it so try this...</p>

<pre><code>{% for image in block.image.all() %}{{ image.url }}{% endfor %}
</code></pre>

<p>If you want to check that there is an image first you can use this..</p>

<pre><code>{% if block.image|length %} ... {% endif %}
</code></pre>

CC BY-SA 4.0
2020-02-23T07:58:15.123Z
Same result. I get an id of the image and the proper title, but it will not print the url.
analog junkie
CC BY-SA 4.0
2020-02-23T09:43:59.370Z
Why do you need {% if block.type == "image" %} ? Have you defined the block.type as 'image'? try removing it.
Steve
CC BY-SA 4.0
2020-02-22T12:07:02.917Z
2020-02-22T12:31:13.070Z
2020-02-22T12:31:13.070Z
Steve
<p>First time working with matrix fields. In this case to load images. But somehow I can't manage to fetch the url of the Images. I can get the title and id but not the url. Can someone point me to the mistake am am making? Thanks!</p>

<pre><code>{% set allProjects = craft.entries.section(['sectionHandle']) %} 

    {% for projects in allProjects.all() %} 

        {% for block in projects.matrixFieldHandle.all() %}

           {% if block.type == "image" %}

             {% set image = block.image.one() %}
             {% if image %}
              {{ image.url }}
             {% endif %}

           {% endif %}

       {% endfor %}

    {% endfor %}
</code></pre>

CC BY-SA 4.0
2020-02-22T05:55:46.777Z
If you view the source on the page, what gets output where you expect the image URL to be?
Brad Bell
CC BY-SA 4.0
2020-02-23T08:50:40.737Z
I can print {{ image.id }} ... title, width, height, but if I ask for {{ image.url }} there is nothing printed on screen or in the source. It's empty.
analog junkie
CC BY-SA 4.0
2020-02-25T11:46:02.857Z
I have the exact same problem, when I load an url of a channel asset field.
analog junkie
CC BY-SA 4.0
2020-02-25T11:55:37.857Z
Is it possible that it has to do with the fact, that the site runs on mamp?
analog junkie
<matrix>
Images of Matrix not loading
# Images of Matrix not loading

(Asked by: username_0 on 2020-02-21)

First time working with matrix fields. In this case to load images. But somehow I can't manage to fetch the url of the Images. I can get the title and id but not the url. Can someone point me to the mistake am am making? Thanks!
{% set allProjects = craft.entries.section(['sectionHandle']) %} 

    {% for projects in allProjects.all() %} 

        {% for block in projects.matrixFieldHandle.all() %}

           {% if block.type == "image" %}

             {% set image = block.image.one() %}
             {% if image %}
              {{ image.url }}
             {% endif %}

           {% endif %}

       {% endfor %}

    {% endfor %}

**Tags:** matrix
> **Comments:**
> **username_1**: If you view the source on the page, what gets output where you expect the image URL to be?  
> **username_0**: I can print {{ image.id }} ... title, width, height, but if I ask for {{ image.url }} there is nothing printed on screen or in the source. It's empty.  
> **username_0**: I have the exact same problem, when I load an url of a channel asset field.  
> **username_0**: Is it possible that it has to do with the fact, that the site runs on mamp?  

---

## 3 answers

### Answer by username_2 on 2020-03-24. Score: 2

during this process :
`{% set image = block.image.one() %}`
please make sure the name of handle of image is image.
For example in this matrix the type is 'image' but to get image url you should call it. item.imageAssets.one().url
[![Matrix](https://i.sstatic.net/bew2V.png)](https://i.sstatic.net/bew2V.png)


---

### Answer by username_3 on 2020-02-22. Score: 1

Try checking for |length
         {% if image|length %}
          {{ image.url }}
         {% endif %}

> **Comments:**
> **username_0**: Still. Other parameters of the image are printed like id or title but not the url.  

---

### Answer by username_4 on 2020-02-22. Score: 1

block.image is actually an array (even if only 1 image in it) therefore you need to loop over it so try this...
{% for image in block.image.all() %}{{ image.url }}{% endfor %}

If you want to check that there is an image first you can use this..
{% if block.image|length %} ... {% endif %}

> **Comments:**
> **username_0**: Same result. I get an id of the image and the proper title, but it will not print the url.  
> **username_4**: Why do you need {% if block.type == "image" %} ? Have you defined the block.type as 'image'? try removing it.  

---

