Cover image on homepage

Hey!

Somewhat confused for the use of an image with the name COVER.
Used as in the systematics of ‘notes’ from the STARTERKIT (because of the use of TAGS).

A list of pages on the home page is to be output.
When using an image with the name HERO it works.
When using an image with the name COVER it does not work = ERROR.

What do I have to change in the 2nd code example to output the COVER image on the homepage?

→ OK for IMAGE named HERO for a page list with tags (like STARTERKIT)

<?php foreach (page('notes')->children()->limit(4)->listed() as $notes): ?>
URL: <?= $notes->url() ?> --
<?php $images =  $notes->hero()->toFiles(); foreach($images as $image): ?>
IMAGE: <?= $image->url() ?><?php endforeach ?>
<?php endforeach ?>

→ ERROR for IMAGE named COVER for a page list with tags (like STARTERKIT)

<?php foreach (page('notes')->children()->limit(4)->listed() as $notes): ?>
URL: <?= $notes->url() ?> --
<?php $images =  $notes->cover()->toFiles(); foreach($images as $image): ?>
IMAGE: <?= $image->url() ?><?php endforeach ?>
<?php endforeach ?>

The note pages in the Starterkit use a page model method called cover, which returns either a single image from the cover field or falls back to the first image in the file system.

Therefore, if you want to use the cover field differently, you have to remove the method from the model (/site/models/note.php) or use $notes->content()->get('cover')->toFiles() to fetch the field directly instead of the method.

We explain that in the annotations in the Starterkit (in the note.php template), but you might have missed it.

Thank you :slight_smile:

This work for me: ->get('cover') complete:

→ OK for IMAGE named COVER for a page list with tags (like STARTERKIT)

<?php foreach (page('notes')->children()->limit(4)->listed() as $notes): ?>
URL: <?= $notes->url() ?> --
<?php $images =  $notes->content()->get('cover')->toFiles(); foreach($images as $image): ?>
IMAGE: <?= $image->url() ?><?php endforeach ?>
<?php endforeach ?>