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

How to auto load images from a folder?

Started by Muut Archive 11 years ago · 3 replies · 469 views
11 years ago

Having gone through the forum I know that its possible to auto load images but I dont quite understand how.

I have a section on my site as portfolio (02.portfolio) and I manually add Text, Image and Link to this. I then have (inside 02.portfolio) other folders which contain images and md files to render the sub folders.

The main 02.portfolio page basically links to these subfolders. I have got this aspect to work. What I cant figure out is how do I get these subfolders to automatically output the images as thumbnails and upon clicking them turn them into lightboxes?

11 years ago

OK... So I've tried some things and have not had much luck...

I am using the Deliver template...

Within

/user/pages/02.portfolio/
I have a file called modular_alt.md which points to the folder _portfolio
Within _portfolio I have images and a file called portfolio.md
I modified portfolio.html.twig so that images do not open in a lightbox instead they open a new page as defined in portfolio.md. The content within this links to the below page I made. I would be making several more pages like this and linking them from this page. This aspect is working.

Within
/user/pages/02.portfolio/2-dark-wallpapers
I have a modular_alt.md file (points to _portfolio)
I also created a _portfolio folder that contains about 10 images and a file called wallpaper.md (which is pulling in wallpaper.html.twig). The wallpaper.md is a copy of portfolio.md and as yet I have not modified wallpaper.md as I am ensure what to put inside it in order to get images to auto appear. wallpaper.md contains some text I want on this page in particular.

Within
\user hemes\deliver emplates\modular\
I copi ed portfolio.html.twig and renamed it to wallpaper.html.twig (mainly because I have modified portfolio.html.twig already to work with the page 02.portfolio as mentioned above). wallpaper.html.twig does not contain the changes I made to portfolio.html.twig so its the stock deliver portfolio twig file just renamed.

Now I know that I need to modify wallpaper.html.twig so that it automatically loads images into the page, resizes them into thumbnails and upon clicking them opens up a lightbox. I read the Learn section but could not figure out the media part to make it work like I want to. I've tried replacing some elements in wallpaper.html.twig with what I have found in this forum but usually I ended up breaking this page entirely.

11 years ago

I've replied to your question in the Gitter chat :) Talk to you there.

11 years ago

Yep thanks, all working perfectly now :D

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1323 9 years ago
Archive · by Muut Archive, 9 years ago
2 920 9 years ago
Archive · by Muut Archive, 9 years ago
2 4048 9 years ago
Archive · by Muut Archive, 9 years ago
1 2924 9 years ago
Archive · by Muut Archive, 9 years ago
3 1106 9 years ago