<p>Ok, think I know what's wrong – you want to select the first asset, but not its url. E.g.</p>
<pre><code>{{ svg(callout.icon.one()) }}
</code></pre>

CC BY-SA 4.0
2020-06-24T13:49:12.867Z
Yes! That was it. Thank you so much :)
Jake1293
CC BY-SA 4.0
2020-06-24T13:31:46.120Z
2020-06-24T14:10:36.067Z
2020-06-24T14:10:36.067Z
dmatthams
<p>I've set up an asset field inside a matrix field where a user can upload SVG icons, but I'm having trouble outputting them using the svg() function.</p>
<pre><code>{# Correctly shows the path #}
{{ callout.icon[0].url }}

{# Correctly displays the SVG within an image tag #}
&lt;img src = &quot;{{ callout.icon[0].url }}&quot; alt=&quot;&quot;  /&gt;

{# No output #}
{{ svg(callout.icon[0].url) }}
{{ svg(callout.icon) }}
</code></pre>
<p>Can anyone see what I'm doing wrong with the svg() function? Other than being inside a matrix field, what I'm doing doesn't seem to differ from the example in <a href="https://docs.craftcms.com/v3/dev/functions.html#svg" rel="nofollow noreferrer">the documentation</a>. I'm trying to avoid using any plugins if at all possible.</p>

CC BY-SA 4.0
2020-06-24T09:28:11.087Z
Do you get any kind of error in the logs? Just out of interest have you tried using `.one()` instead of `[0]` i.e. `{{ svg(callout.icon.one().url) }}`
dmatthams
CC BY-SA 4.0
2020-06-24T13:07:45.770Z
Just tried. Without svg() it correctly displays the path, but with svg() there's no ouput. Are the logs in /craft/stroates/logs/ ? If so, I checked there and searched all the .log.1, .log.2, .log.3 files, for "svg" but nothing came up
Jake1293
<assets-field><svg>
Outputting SVG from an asset field inside a matrix field with svg()
# Outputting SVG from an asset field inside a matrix field with svg()

(Asked by: username_0 on 2020-06-24)

I've set up an asset field inside a matrix field where a user can upload SVG icons, but I'm having trouble outputting them using the svg() function.
{# Correctly shows the path #}
{{ callout.icon[0].url }}

{# Correctly displays the SVG within an image tag #}


{# No output #}
{{ svg(callout.icon[0].url) }}
{{ svg(callout.icon) }}

Can anyone see what I'm doing wrong with the svg() function? Other than being inside a matrix field, what I'm doing doesn't seem to differ from the example in the documentation. I'm trying to avoid using any plugins if at all possible.

**Tags:** assets-field, svg

> **Comments:**
> **username_1**: Do you get any kind of error in the logs? Just out of interest have you tried using `.one()` instead of `[0]` i.e. `{{ svg(callout.icon.one().url) }}`  
> **username_0**: Just tried. Without svg() it correctly displays the path, but with svg() there's no ouput. Are the logs in /craft/stroates/logs/ ? If so, I checked there and searched all the .log.1, .log.2, .log.3 files, for "svg" but nothing came up  

---

## 1 answers

### Answer by username_1 on 2020-06-24. Score: 2 | Accepted answer

Ok, think I know what's wrong – you want to select the first asset, but not its url. E.g.
{{ svg(callout.icon.one()) }}

> **Comments:**
> **username_0**: Yes! That was it. Thank you so much :)  

---

