Answers.Body: <p>Here is what I would do:</p>
  
  <p>First, make an actual array of all the images (using <a href="http://buildwithcraft.com/docs/templating/elementcriteriamodel#find" rel="nofollow">find</a> to make the array):</p>
  
  <pre><code>{% set imageArray = craft.assets.folderId('2').find() %}
  </code></pre>
  
  <p>Then, loop over the entries:</p>
  
  <pre><code>{% for row in entry.howItWorksTable %}
  </code></pre>
  
  <p>and in that loop each time you display a row, you can get the corresponding image (using the <a href="http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable" rel="nofollow">loop variable</a> <code>index0</code>):</p>
  
  <pre><code>{% set image = imageArray[loop.index0] %}
  </code></pre>
  
  <p>Putting it all together:</p>
  
  <pre><code>{% set imageArray = craft.assets.folderId('2').find() %}
  
  {% if entry.howItWorksTable | length %}
    &lt;table&gt;
      {% for row in entry.howItWorksTable %}
        &lt;tr&gt;
          &lt;td&gt;&lt;img src="{{ image.getUrl() }}"&gt;{{ row.stages }}&lt;/td&gt;
          &lt;td&gt;{{ row.skillsLearnt }}&lt;/td&gt;
          &lt;td&gt;{{ row.classes }}&lt;/td&gt;
          &lt;td&gt;{{ row.price }}&lt;/td&gt;
        &lt;/tr&gt;  
      {% endfor %}
    &lt;/table&gt;
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-27T17:42:59.017Z
Answers.Text: I was wondering where the looped image index is specified within the code above?
Answers.UserDisplayName: buck1112
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-09T15:59:29.287Z
Answers.LastActivityDate: 2015-07-09T15:59:29.287Z
Answers.UserDisplayName: Marion Newlevant
Body: <p>Thanks in advance to anyone who can help me :)</p>
  
  <p>I have a table field in Craft that my template is pulling in data from... the issue is that in the box at the start of each row I want a different image. </p>
  
  <p>Every time the loop goes round and pulls in the data for each row from the table in Craft I also want it to pull in an image using <code>craft.assets.folderId()</code>.</p>
  
  <p>Here is my code so far.. it pulls in the individual images but it repeats the the first row of the table for each image... and then it pulls in all the the images again repeating the next row and so on...
  please see this link to get an idea of what I mean: <a href="http://code7dev11.co.uk/how-it-works" rel="nofollow">http://code7dev11.co.uk/how-it-works</a></p>
  
  <pre><code>{% if entry.howItWorksTable | length %}
          &lt;table&gt;
              {% for row in entry.howItWorksTable %}
                  {% for image in craft.assets.folderId('2') %}
                  &lt;tr&gt;
                      &lt;td&gt;&lt;img src="{{ image.getUrl() }}"&gt;{{ row.stages }}&lt;/td&gt;
                      &lt;td&gt;{{ row.skillsLearnt }}&lt;/td&gt;
                      &lt;td&gt;{{ row.classes }}&lt;/td&gt;
                      &lt;td&gt;{{ row.price }}&lt;/td&gt;
                  &lt;/tr&gt;  
                  {% endfor %}
              {% endfor %}
          &lt;/table&gt;
  {% endif %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-08T17:36:49.307Z
Comments.Text: Wouldn't it be easier to just use Matrix for this?  That way you can link directly to the images that you want using a proper Assets field.
Comments.UserDisplayName: Brad Bell
Tags: <assets><table>
Title: Pull in images to table rows using craft.assets wilst looping through a table field
ThreadText: # Pull in images to table rows using craft.assets wilst looping through a table field
  
  (Asked by: username_0 on 2015-07-08)
  
  Thanks in advance to anyone who can help me :)
  
  I have a table field in Craft that my template is pulling in data from... the issue is that in the box at the start of each row I want a different image.
  
  Every time the loop goes round and pulls in the data for each row from the table in Craft I also want it to pull in an image using `craft.assets.folderId()`.
  
  Here is my code so far.. it pulls in the individual images but it repeats the the first row of the table for each image... and then it pulls in all the the images again repeating the next row and so on...
  please see this link to get an idea of what I mean: <http://code7dev11.co.uk/how-it-works>
  
  ```
  {% if entry.howItWorksTable | length %}
          <table>
              {% for row in entry.howItWorksTable %}
                  {% for image in craft.assets.folderId('2') %}
                  <tr>
                      <td><img src="{{ image.getUrl() }}">{{ row.stages }}</td>
                      <td>{{ row.skillsLearnt }}</td>
                      <td>{{ row.classes }}</td>
                      <td>{{ row.price }}</td>
                  </tr>  
                  {% endfor %}
              {% endfor %}
          </table>
  {% endif %}
  
  ```
  
  **Tags:** assets, table
  
  > **Comments:**
  > **username_1**: Wouldn't it be easier to just use Matrix for this?  That way you can link directly to the images that you want using a proper Assets field.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-07-09. Score: 1
  
  Here is what I would do:
  
  First, make an actual array of all the images (using [find](http://buildwithcraft.com/docs/templating/elementcriteriamodel#find) to make the array):
  
  ```
  {% set imageArray = craft.assets.folderId('2').find() %}
  
  ```
  
  Then, loop over the entries:
  
  ```
  {% for row in entry.howItWorksTable %}
  
  ```
  
  and in that loop each time you display a row, you can get the corresponding image (using the [loop variable](http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable) `index0`):
  
  ```
  {% set image = imageArray[loop.index0] %}
  
  ```
  
  Putting it all together:
  
  ```
  {% set imageArray = craft.assets.folderId('2').find() %}
  
  {% if entry.howItWorksTable | length %}
    <table>
      {% for row in entry.howItWorksTable %}
        <tr>
          <td><img src="{{ image.getUrl() }}">{{ row.stages }}</td>
          <td>{{ row.skillsLearnt }}</td>
          <td>{{ row.classes }}</td>
          <td>{{ row.price }}</td>
        </tr>  
      {% endfor %}
    </table>
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_3**: I was wondering where the looped image index is specified within the code above?  
  
  ---
  
  