<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>

CC BY-SA 4.0
2018-07-27T17:42:59.017Z
I was wondering where the looped image index is specified within the code above?
buck1112
CC BY-SA 3.0
2015-07-09T15:59:29.287Z
2015-07-09T15:59:29.287Z
Marion Newlevant
<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>

CC BY-SA 3.0
2015-07-08T17:36:49.307Z
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.
Brad Bell
<assets><table>
Pull in images to table rows using craft.assets wilst looping through a table field
# 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 %}
        
            {% for row in entry.howItWorksTable %}
                {% for image in craft.assets.folderId('2') %}
                
                    {{ row.stages }}
                    {{ row.skillsLearnt }}
                    {{ row.classes }}
                    {{ row.price }}
                  
                {% endfor %}
            {% endfor %}
        
{% 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 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 index0):
{% set image = imageArray[loop.index0] %}

Putting it all together:
{% set imageArray = craft.assets.folderId('2').find() %}

{% if entry.howItWorksTable | length %}
  
    {% for row in entry.howItWorksTable %}
      
        {{ row.stages }}
        {{ row.skillsLearnt }}
        {{ row.classes }}
        {{ row.price }}
        
    {% endfor %}
  
{% endif %}

> **Comments:**
> **username_3**: I was wondering where the looped image index is specified within the code above?  

---

