Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

List every images in folder

Started by Muut Archive 11 years ago · 1 replies · 419 views
11 years ago

Hello,
I have in every pages-folder an images-folder where the user can include background-images for an integrated slider.
In my base.html.twig, I wanted to list all the images in the pages folder and tried to to this with this code:

TWIG
{% for image in page.media.images %}
   {{ image.url }}
{% endfor %}

I thought it should work (I saw this method in a skeleton from GRAV) but it doesn't – it just returns nothing but my images-folder exists and contains two images.
My goal are the URLs of these images. What is my mistake?

11 years ago

The images need to be in the same folder as the .md file, not in an another images/ folder. That's not needed and just breaking how Grav works.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1346 9 years ago
Archive · by Muut Archive, 9 years ago
2 933 9 years ago
Archive · by Muut Archive, 9 years ago
2 4060 9 years ago
Archive · by Muut Archive, 9 years ago
1 2945 9 years ago
Archive · by Muut Archive, 9 years ago
3 1117 9 years ago