Hi all,
Struggling with this one, I am calling random images from a specific template, with the following snippet below, which is working great. How might bring I also echo their corresponding image captions? All of the images have accompanying caption txt files.
Thanking you in advanced for your help!
<div class="random-image-article">
<a href="index">
<?php
// find pages with tag + images
$pagesWithImage = $site->index()->visible()->filterBy('template', 'in', ['maps', '']);
// pick random page + random image
if ($pagesWithImage->count()) {
$newtag = $pagesWithImage->shuffle()->first()->images()->shuffle()->first();
}
// resize image
if ($newtag) {
echo $newtag->thumb()->html();
}
?></a>
</div>