<?php snippet('header')?>
<?= $page->title() ?>
<ul>
<?php foreach($page->children()->listed() as $project): ?>
<li>
<a href="<?= $project->url()?>">
<figure>
<?= $project->image()->crop(400) ?>
<figcaption><?= $project->title() ?></figcaption>
</figure>
</a>
</li>
<?php endforeach; ?>
</ul>
</main>
<?php snippet('footer')?>
texnixe
2
The error message means that one (or more) of your pages in the loop don’t have an image.
To prevent such type of errors, you always need to check if an object (in this case a file object) exists before calling a member method like crop
.
<?php if ($image = $project->image()): ?>
<figure>
<?= $image->crop(400) ?>
<figcaption><?= $project->title() ?></figcaption>
</figure>
<?php endif ?>