Answers.Body: <p>I'm not sure what <code>{% for image in craft.assets.kind('image') %}</code> is all about in your code since the <code>image</code> variable isn't being used anywhere.</p>
  
  <p>But here's the basic structure on how you could loop through 3 separate Asset fields in 3 different single sections inside of a Matrix block:</p>
  
  <pre><code>{% for block in entry.homeMatrix %}
      {% if block.type == "homeMatrix" %}
  
          {% set firstSingle = craft.entries.section('myFirstSection').first() %}
          {% set secondSingle = craft.entries.section('mySecondSection').first() %}
          {% set thirdSingle = craft.entries.section('myThirdSection').first() %}
  
          {% if firstSingle.myAssetField|length %}
              {% for image in firstSingle.myAssetField %}
                  {{ image.url }}
              {% endfor %}
          {% endif %}
  
          {% if secondSingle.myAssetField|length %}
              {% for image in secondSingle.myAssetField %}
                  {{ image.url }}
              {% endfor %}
          {% endif %}
  
          {% if thirdSingle.myAssetField|length %}
              {% for image in thirdSingle.myAssetField %}
                  {{ image.url }}
              {% endfor %}
          {% endif %}
  
      {% endif %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-04T19:09:47.617Z
Answers.LastActivityDate: 2015-06-04T19:09:47.617Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am trying to loop through a matrix to output three blocks but also I want to pull in 3 images from 3 different sections. The images are asset fields in 3 other sections. should i loop through those sections using craft.entries or craft.assests? below is an example of what i have been trying out. thanks in advance for any help</p>
  
  <pre><code>{% for block in entry.homeMatrix %}
          {% if block.type == "homeMatrix" %}
                  &lt;a class="half-box full-box" href="{{ block.entry.first().url }}"&gt;
                      {% for image in craft.assets.kind('image') %}
                      &lt;picture class="box-image"&gt;
                          &lt;!--[if IE 9]&gt;&lt;video style="display: none;"&gt;&lt;![endif]--&gt;
                              &lt;source srcset="{{ entry.lTopBannerImg.first().url('gridImages480X340') }}" media="(min-width: 45em)"&gt;
                              &lt;source srcset="{{ entry.lTopBannerImg.first().url('gridImageOdd559X315') }}" media="(min-width: 28.4375em)"&gt;
                              &lt;source srcset="{{ entry.lTopBannerImg.first().url('gridImages560X520') }}"&gt;
                          &lt;!--[if IE 9]&gt;&lt;/video&gt;&lt;![endif]--&gt;
                          &lt;img alt="{{ entry.lTopBannerImgAltText.first().title }}" srcset="{{ entry.lTopBannerImg.first().url('gridImages480X340') }}"&gt;
                      &lt;/picture&gt;
                      {% endfor %}
                      &lt;div class="box-bar"&gt;
                          &lt;h2&gt;{{ block.url }}&lt;/h2&gt;
                      &lt;/div&gt;
                      &lt;div class="see-more"&gt;&lt;span class="plus"&gt;Click to see more information&lt;/span&gt;&lt;/div&gt;
  
                  &lt;/a&gt;
          {% endif %}
      {% endfor %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-04T09:01:53.987Z
Comments.Text: Are the three sections whose asset field you want to pull in Singles, or Channels?
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-04T09:04:48.287Z
Comments.Text: They are singles :)
Comments.UserDisplayName: Steve
Tags: <matrix><loop>
Title: pulling in an image from another section within a matrix loop
ThreadText: # pulling in an image from another section within a matrix loop
  
  (Asked by: username_0 on 2015-06-04)
  
  I am trying to loop through a matrix to output three blocks but also I want to pull in 3 images from 3 different sections. The images are asset fields in 3 other sections. should i loop through those sections using craft.entries or craft.assests? below is an example of what i have been trying out. thanks in advance for any help
  
  ```
  {% for block in entry.homeMatrix %}
          {% if block.type == "homeMatrix" %}
                  <a class="half-box full-box" href="{{ block.entry.first().url }}">
                      {% for image in craft.assets.kind('image') %}
                      <picture class="box-image">
                          <!--[if IE 9]><video style="display: none;"><![endif]-->
                              <source srcset="{{ entry.lTopBannerImg.first().url('gridImages480X340') }}" media="(min-width: 45em)">
                              <source srcset="{{ entry.lTopBannerImg.first().url('gridImageOdd559X315') }}" media="(min-width: 28.4375em)">
                              <source srcset="{{ entry.lTopBannerImg.first().url('gridImages560X520') }}">
                          <!--[if IE 9]></video><![endif]-->
                          <img alt="{{ entry.lTopBannerImgAltText.first().title }}" srcset="{{ entry.lTopBannerImg.first().url('gridImages480X340') }}">
                      </picture>
                      {% endfor %}
                      <div class="box-bar">
                          <h2>{{ block.url }}</h2>
                      </div>
                      <div class="see-more"><span class="plus">Click to see more information</span></div>
  
                  </a>
          {% endif %}
      {% endfor %}
  
  ```
  
  **Tags:** matrix, loop
  
  > **Comments:**
  > **username_1**: Are the three sections whose asset field you want to pull in Singles, or Channels?  
  > **username_0**: They are singles :)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-06-04. Score: 3 | Accepted answer
  
  I'm not sure what `{% for image in craft.assets.kind('image') %}` is all about in your code since the `image` variable isn't being used anywhere.
  
  But here's the basic structure on how you could loop through 3 separate Asset fields in 3 different single sections inside of a Matrix block:
  
  ```
  {% for block in entry.homeMatrix %}
      {% if block.type == "homeMatrix" %}
  
          {% set firstSingle = craft.entries.section('myFirstSection').first() %}
          {% set secondSingle = craft.entries.section('mySecondSection').first() %}
          {% set thirdSingle = craft.entries.section('myThirdSection').first() %}
  
          {% if firstSingle.myAssetField|length %}
              {% for image in firstSingle.myAssetField %}
                  {{ image.url }}
              {% endfor %}
          {% endif %}
  
          {% if secondSingle.myAssetField|length %}
              {% for image in secondSingle.myAssetField %}
                  {{ image.url }}
              {% endfor %}
          {% endif %}
  
          {% if thirdSingle.myAssetField|length %}
              {% for image in thirdSingle.myAssetField %}
                  {{ image.url }}
              {% endfor %}
          {% endif %}
  
      {% endif %}
  {% endfor %}
  
  ```
  
  
  ---
  
  