Answers.Body: <p>I'd suggest giving the Matrix <a href="https://craftcms.com/docs/matrix-fields#templating" rel="nofollow noreferrer">templating</a> docs a once-over.</p>
  <p>If <code>steps</code> is the name of your Matrix field, then <code>{% for row in entry.steps %}</code> is going to be looping over each of the Matrix blocks you've defined.</p>
  <p>Then you'd want to check for the stepImage asset field in the correct block. i.e.</p>
  <pre><code>{% for block in entry.steps %}
      {% if block.type == 'myBlock' %}
           {% set image = block.stepImage.one() %}
         
           {% if image %}
               {{image.url}}
           {% endif %}
      {% endif %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-04-06T17:07:02.093Z
Answers.LastActivityDate: 2020-12-30T19:08:55.667Z
Answers.LastEditDate: 2020-12-30T19:08:55.667Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have got a problem with an asset field in a Matrix in an _entry template.
  The Matrix is for a step-by-step feature. Each step has his own image.
  So the asset field in my Matrix calls: <code>stepImage</code>.</p>
  
  <p>Now in my <code>_entry</code> template I loop over the step Matrix like:</p>
  
  <pre><code>{% for row in entry.steps %}
      ...
  {% endfor %}
  </code></pre>
  
  <p>In this loop I try to get the asset URL like:</p>
  
  <pre><code>  {% set image = row.stepImage.first() %}
    {% if image %}
        {{image.url}}
    {% endif %}
  </code></pre>
  
  <p>but it does not work. If i dump it, it returns <code>bool(false)</code>.</p>
  
  <p>Do you have any ideas?</p>
  
Tags: <assets><matrix><entry>
Title: How to get Image/Asset URL in Matrix?
ThreadText: # How to get Image/Asset URL in Matrix?
  
  (Asked by: username_0 on 2017-04-06)
  
  I have got a problem with an asset field in a Matrix in an \_entry template.
  The Matrix is for a step-by-step feature. Each step has his own image.
  So the asset field in my Matrix calls: `stepImage`.
  
  Now in my `_entry` template I loop over the step Matrix like:
  
  ```
  {% for row in entry.steps %}
      ...
  {% endfor %}
  
  ```
  
  In this loop I try to get the asset URL like:
  
  ```
    {% set image = row.stepImage.first() %}
    {% if image %}
        {{image.url}}
    {% endif %}
  
  ```
  
  but it does not work. If i dump it, it returns `bool(false)`.
  
  Do you have any ideas?
  
  **Tags:** assets, matrix, entry
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-04-06. Score: 1
  
  I'd suggest giving the Matrix [templating](https://craftcms.com/docs/matrix-fields#templating) docs a once-over.
  
  If `steps` is the name of your Matrix field, then `{% for row in entry.steps %}` is going to be looping over each of the Matrix blocks you've defined.
  
  Then you'd want to check for the stepImage asset field in the correct block. i.e.
  
  ```
  {% for block in entry.steps %}
      {% if block.type == 'myBlock' %}
           {% set image = block.stepImage.one() %}
         
           {% if image %}
               {{image.url}}
           {% endif %}
      {% endif %}
  {% endfor %}
  
  ```
  
  
  ---
  
  