Access $entry from within a kirbytext handler

Hi there,

I’m currently trying to build a kirbytext handler for an image gallery for a blog.

(gallery) kirbytext handler
USAGE: (gallery: <all|pic1.jpg,pic2.jpg,pic3.jpg>)

For gathering the images I use:

$images = page()->images();

which works perfectly fine, as long as I access the blog entry directly (which is a subpage of the main page “blog”).

But when I open the overview of my blog entries (the parent page “blog”) I don’t get any pictures. Which makes sense, as kirby now looks for pictures attached to the parent page “blog”, which has none.

My approach was to use $entry->images() instead of page()->images() if available, but unfortunately this variable isn’t passed to the kirbytext handler php of my gallery tag.

Does somebody has a suggestion on how to solve this?

Thanks a lot in advance!

You can use $tag->page() and even $tag->files() =>

Oops, I must have missed that in the documentation.

Thank you so much! That worked perfectly fine.