<blockquote>
  <p>I need to grab all images from a section and display them in a slide show on the index page.</p>
</blockquote>

<p>You'll need to:</p>

<ol>
<li>Loop through all of your story entries.</li>
<li>Grab the image from each story.</li>
<li>Compile those into a Twig array.</li>
<li>Create your slideshow as needed.</li>
</ol>

<p>Here's how that all ties together...</p>

<pre><code>{% set storyItems = craft.entries.section('stories').find() %}

{% set previewImages = [] %}

{% for item in storyItems %}
    {% set currentImage = item.slideshowImage.first() %}
    {% set previewImages = previewImages | merge(currentImage) %}
{% endfor %}

{# RENDER YOUR SLIDESHOW FROM previewImages #}
</code></pre>

<p>You'll need to initialize the <code>previewImages</code> array before beginning the <code>for</code> loop... Loops in Twig have their own scope.</p>

<blockquote>
  <p>The limit and offset are just to make the slider I have work...</p>
</blockquote>

<p>I'm not sure exactly what you're trying to do with the <code>offset</code>, but I'd recommend manipulating your images array in Twig (as opposed to fancy queries to target specific images).</p>

CC BY-SA 3.0
2015-10-28T22:28:50.913Z
2015-10-28T22:28:50.913Z
Lindsey D
<p>I am sure this must be answered somewhere and I cannot find it.  I need to grab all images from a section (<strong>channel</strong>) and display them in a slide show on the index page (index page is a <strong>single</strong>,so index page of the entries from that section). I just cannot seem to get this correct.  Here is what I am trying </p>

<pre><code> {% set storyItem = craft.entries.section('stories').find() %}
</code></pre>

<p>so stories is the section where the entries are.</p>

<p>Then </p>

<pre><code>{% for previewImage in storyItem.slideshowImage.offset(1) %} 
 ...
{% for previewImage in storyItem.slideshowImage.limit(1) %} 
...
{% for previewImage in storyItem.slideshowImage.offset(1) %}  
</code></pre>

<p>The limit and offset are just to make the slider I have work and that does work on another page so that does not seem to be what is stopping me here.  I am somewhat new to craft and my gut is telling me this is a simple answer but I have been stuck on it for a while now and coming back to it off and on to no avail.</p>

CC BY-SA 3.0
2015-10-28T20:41:52.370Z
Just to be clear, is this a Single section?  Otherwise, you want to grab every image from every field from every entry/entrytype in a section?
Brad Bell
CC BY-SA 3.0
2015-10-28T20:43:07.003Z
So the section I want to grab from is a channel (stories), and I am trying to display them on a single, which displays all entries for that channel further down the page.  I hope I am explaining that clearly,  I think what I am trying to do is the second part of you question, grab all from that section.
Rockwell Rice
<templating><craft3>
How to grab all images from and section
# How to grab all images from and section

(Asked by: username_0 on 2015-10-28)

I am sure this must be answered somewhere and I cannot find it.  I need to grab all images from a section (channel) and display them in a slide show on the index page (index page is a single,so index page of the entries from that section). I just cannot seem to get this correct.  Here is what I am trying 
 {% set storyItem = craft.entries.section('stories').find() %}

so stories is the section where the entries are.
Then 
{% for previewImage in storyItem.slideshowImage.offset(1) %} 
 ...
{% for previewImage in storyItem.slideshowImage.limit(1) %} 
...
{% for previewImage in storyItem.slideshowImage.offset(1) %}  

The limit and offset are just to make the slider I have work and that does work on another page so that does not seem to be what is stopping me here.  I am somewhat new to craft and my gut is telling me this is a simple answer but I have been stuck on it for a while now and coming back to it off and on to no avail.

**Tags:** templating, craft3

> **Comments:**
> **username_1**: Just to be clear, is this a Single section?  Otherwise, you want to grab every image from every field from every entry/entrytype in a section?  
> **username_0**: So the section I want to grab from is a channel (stories), and I am trying to display them on a single, which displays all entries for that channel further down the page.  I hope I am explaining that clearly,  I think what I am trying to do is the second part of you question, grab all from that section.  

---

## 1 answers

### Answer by username_2 on 2015-10-28. Score: 3 | Accepted answer

I need to grab all images from a section and display them in a slide show on the index page.

You'll need to:

Loop through all of your story entries.
Grab the image from each story.
Compile those into a Twig array.
Create your slideshow as needed.

Here's how that all ties together...
{% set storyItems = craft.entries.section('stories').find() %}

{% set previewImages = [] %}

{% for item in storyItems %}
    {% set currentImage = item.slideshowImage.first() %}
    {% set previewImages = previewImages | merge(currentImage) %}
{% endfor %}

{# RENDER YOUR SLIDESHOW FROM previewImages #}

You'll need to initialize the previewImages array before beginning the for loop... Loops in Twig have their own scope.

The limit and offset are just to make the slider I have work...

I'm not sure exactly what you're trying to do with the offset, but I'd recommend manipulating your images array in Twig (as opposed to fancy queries to target specific images).


---

