Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-24T13:49:12.867Z
Answers.Text: Yes! That was it. Thank you so much :)
Answers.UserDisplayName: Jake1293
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-24T13:31:46.120Z
Answers.LastActivityDate: 2020-06-24T14:10:36.067Z
Answers.LastEditDate: 2020-06-24T14:10:36.067Z
Answers.UserDisplayName: dmatthams
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-24T09:28:11.087Z
Comments.Text: 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) }}`
Comments.UserDisplayName: dmatthams
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-24T13:07:45.770Z
Comments.Text: 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
Comments.UserDisplayName: Jake1293
Tags: <assets-field><svg>
Title: Outputting SVG from an asset field inside a matrix field with svg()
ThreadText: # 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 #}
  <img src = "{{ callout.icon[0].url }}" alt=""  />
  
  {# 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](https://docs.craftcms.com/v3/dev/functions.html#svg). 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 :)  
  
  ---
  
  