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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Display all images in folder for shortcode gallery plugin

first-time plugins

Started by Safiro 4 years ago · 2 replies · 810 views
4 years ago

Hello,

I am fairly new to grav. I have used the plugin shortcode gallery plus plus for my site. So, for the plugin to work, the image links must be entered within the [gallery][/gallery] tags in the page markdown file. It works fine, but I'm trying to display all images within the page folder without having to add links to each image in the markdown file.

So I tried another code within the page twig.

{% extends 'partials/base.html.twig' %}
{% block content %}

TWIG
<div class="content">
    <h1 class="page-title">{{page.title}}</h1>
    <hr class="header-hr">
    {{ page.content|raw }}

{% for image in page.media.images %}
"<img src="{{ image.url }}">"
{% endfor %}

TXT
</div>

{% endblock %}

This works fine and displays all images within the page folder, but my problem is how and where to insert the [gallery][/gallery] tags for the plugin to work. I want the images to be displayed as thumbnails and open in modal pop up when clicked. The plugin does that.

Any help is much appreciated!
Thanks!

4 years ago

The shortcode provided by this plugin is intended for page markdown, not the Twig templates as you are asking about. At least according to its README file, it doesn't provide any Twig invocations.

You can embed markdown in Twig and I'm guessing it will work for shortcodes too. Try Grav's markdown custom Twig tag, put your [gallery][/gallery] in there.

4 years ago

Ah, you might be correct. I'll check the link and give it another go to try and embed the tags in the twig ;)

Thank you

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 97 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 185 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 148 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 61 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 255 1 year ago