Can't figure out how to display cover image

I see. Slowly getting there - much to read, much to learn. Especially when to use which method.

How can I iterate on the way to show the cover on the frontend view of the parent “productions” page? I can use the generic image check and get the first image, but I really like to check for & show the image with the “cover” template…

<?php foreach ($page->children()->listed() as $item): ?>
    <a href="<?= $item->url() ?>"><?= $item->title() ?>
        <?php if ($image = $item->images->findBy('template','cover')): ?>
            <img src="<?= $item->image()->url() ?>" alt="<?= $item->image()->alt() ?>">
        <?php endif ?>
    </a>
<?php endforeach ?>

Appreciate the help immensely!

Almost, but you need to use the $image variable you defined, with your code, you fetch the intended image in the $image variable, but then display another image ($item->image(), which returns the first image in the folder). Also parentheses missing. Correct code:

<?php if ($image = $item->images()->findBy('template','cover')): ?>
   <img src="<?= $image->url() ?>" alt="<?= $image->alt() ?>">
<?php endif ?>

Ha! Looks so simple :slight_smile:
… and after some time with Kirby it proves to be simple as well

Thanks for making my day!