Authors-System error


#1

Hi,
i’m trying to follow this tutorial for getting an author system: Author-System

i’m able to get the suggested author-listing-page to work…
but the article-template does not work

i get this error:
Call to a member function url() on null

it’s a bout this line:
<img src="<?php echo $author->images()->first()->url() ?>">

thx in advance


#2

When working with objects (like an image in this case), always check if it exists before calling a method (like url()) on it:

<php
$image = $author->images()->first(); //  `$author->image()` would give you the first image as well
if($image): 
?>
  <img src="<?= $image->url() ?>">
<?php endif ?>

#3

that helped… got it to work with my template… thx a lot