I’m trying to create a basic kirbytag for my website that allows our editors to input a comma-delimited list of images uploaded to a Kirby post. I’m running into a small snag where I can’t figure out how to get the current page information so I can link to the file path of the files (as dragging the file only gives the file name itself).
Here’s the code:
kirbytext::$tags['gallery'] = array(
'html' => function($tag) {
// variables
$images = explode(',', $tag->attr('gallery'));
// [GALLERY OPENING TAGS]
$structure = '<div class="photoswipe-gallery"><div class="row">';
// add the images to the gallery HTML structure
foreach($images as $image) {
$structure .= '<figure class="col-xs-12 col-sm-4"><a href="/resources/images/review/screenshot_1.png" data-size="1920x1080"><img class="img-thumbnail" src="/resources/images/review/screenshot_1.png" alt="" /></a></figure>';
}
// [GALLERY CLOSING TAGS]
$structure .= '</div></div>';
return $structure;
}
);
And here’s an instance of how the tag works:
(gallery: screenshot_1.png,screenshot_2.png,screenshot_3.png)
Any ideas?