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

Brand new to Grav - displaying all images question

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

Hi - would appreciate some help - am trying to extend the Blog starter theme - by adding more images to the blog post detail page - under the text content. Could someone show/explain the code needed to do this? I have populated the folder of the blog entry with more images - and just need to now display them on the main post page. Do I have to explicitly name each image in the .md file? Or can they be called from the twig template to just list all images out, etc... thanks so much. Apologies if this is basic stuff!

11 years ago

Something like this:

TWIG
    <ul>
    {% for image in page.media.images %}
    <li>
        <h2>{{ image.get('filename') }}</h2>
        {{ image.cropResize(75,75).html }}
    </li>
    {% endfor %}
</ul>

This will get all the images associated with a page and print them out in a list.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1330 9 years ago
Archive · by Muut Archive, 9 years ago
2 922 9 years ago
Archive · by Muut Archive, 9 years ago
2 4052 9 years ago
Archive · by Muut Archive, 9 years ago
1 2930 9 years ago
Archive · by Muut Archive, 9 years ago
3 1109 9 years ago