Upgrading to 2: “Cannot access protected property” error

I am trying to upgrade from Kirby 1 to 2.1.1. I have followed the instructions in the “Upgrade from Kirby 1” document.

Now, on some pages, I get an error that says:

Fatal error: Cannot access protected property File::$name in […path obfuscated…]/site/snippets/media.php on line 6

Here is what the relevant portion of that file looks like:

<? //Images
  if($page->hasImages()): ?>
    <? foreach($page->images() as $image): ?>
      <? if($image->name != "thumb"): ?>
      <div class="image">
        <img src="<?= $image->url() ?>" width="<?= $image->width() ?>" height="<?= $image->height() ?>">
      <? endif ?>
    <? endforeach ?>
  <? endif ?>

Basically, the idea is to loop through all images and display them on the page unless the image is called thumb, e.g. thumb.png or thumb.jpg.

The documentation indicates that for a $file object, the name value should exist. So why am I seeing this error, and how can I resolve it?

It should be

$image->name()  //not $image->name

Right you are. Thank you!