Linking all images in a folder to a blog post

Hi!

I’m building my blog with Kirby, loving it so far.
I’ve made 2 templates: 1 for text (article.text) and 1 for my photo posts (article.photo).
Works great so far.

Now, i want to make an archive for my photo posts.
If i make a blog post with say 5 photos in it, i want the archive to show all 5 photos and link all 5 photos to that blog 1 blog post.

I got it so far that my archive shows the photos in the posts, but i can not make them link to the respective blog posts.
Here is what i have so far:

<?php foreach(page('blog')->children()->visible()->filterBy('tags', 'photo', ',')->flip()->images() as $item): ?>
<a href="<?= $item->url() ?>">   
  <img src="<?= $item->resize(200)->url() ?>">
 </a>
<?php endforeach ?>

So it now shows the photos that i’ve uploaded to my blog posts, but it links to the images itself and not the correct post.

I’m stuck…

Since a file belongs to a page, a file has a page method:

<a href="<?= $item->page()->url() ?>">   
  <img src="<?= $item->resize(200)->url() ?>">
</a>
2 Likes

YES! You are a hero!