Problem loading images, following Bastians video - https://www.youtube.com/watch?v=QwjX8JAwBws

Hi, been following Bastian’s video Kirby3: How to build a website from scratch - I’ve replaced the “projects” with “paintings”. The following code - that I’ve copied from the video - is giving error
“This page is currently offline due to an unexpected error.”

<?php snippet('header') ?>
<?= $page->text() ?>
  <ul class="paintings">
	<?php foreach ($page->children()->listed() as $painting): ?>
	  	  <li>
	    <a href="<?= $painting->url() ?>">
   	    	  <?= $painting->image->crop(500) ?>
    	  	  <?= $painting->title() ?>
	    </a>
	    </li>
	    <?php endforeach ?> 	
  </ul>
</body>
</html>

Any help much appreciated.

Thanks
David

First of all, please enable debugging in your config to get an usable error displayed on screen:

This line has the error (missing parenthesis after image):

 <?= $painting->image->crop(500) ?>

It should be

 <?= $painting->image()->crop(500) ?>

But before calling crop(), you have to check if the image exists, so

<?php if ($image =  $painting->image()): ?>
<?= $image->crop(500) ?>
<?php endif ?>

On a side note, blocks of code are marked up using three backticks on a separate line before and after the block. <code></code> tags do not work.

Thanks for your instant reply - now works as expected - how long can you stare at something without seeing it?
Didn’t see any note on the 3 backticks to enclose code - did look

I know. That’s why I put it in my answer posts. I don’t really know where would be a good place to put that information. Maybe a pinned post? Or the welcome mail? :thinking:

Where I looked is in the icon bar above the text area

Yep, but the icon bar unfortunately only has the single backticks for inline code, not for code blocks…

Can’t you just add it there?