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

Find Media outside Page

Started by Hugo Dias 9 years ago · 3 replies · 715 views
9 years ago

Hello,
i've a page with _modal sections.
In one _modal I have a gallery and I put all gallery images inside 01.home/_gallery/img.
On my file galley.html.twig I have

TWIG
<section class="gallery slider">
    {% for image in page.find('/_gallery/img').media.images %}
        <div>
            <img src="{{ image.url }}" style="width:100%; height:100%">
        </div>      
    {% endfor %}
</section>

and it works OK, any image inside img folder is displayed on the gallery.

But, if I wanted to put all gallery images in another folder, for example 01.home/img (outside the _modal)
I would have
01.home
|_ gallery
|
img

I cannot put the something like
{% for image in page.find('../img').media.images %}
working.

How can I do it?

9 years ago

@hugo:
{% for image in page.find(’…/img’).media.images %}

Hugo,

You might consider putting the images in a single folder.
Have a look in the great documentation

9 years ago

Hello,
Thank you for reply.
I have already tested it, but it won't work,, I don't know if is due to _modal pages inside home page that it won't go to img folder.

9 years ago

@AWRog:
{% for image in page.find(’…/img’).media.images %}

Should be:

TWIG
{% for image in page.find(’/img’).media.images %}

Because the find() method expects a full page route.

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 94 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 146 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 60 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 254 1 year ago