Image from field doesn't go away when deleted from panel

I have a field in the blueprint of a page like this:

  hero:
    label: Hero Image
    type: files

And this is my template code:

          <?php if($hero = $page->image()): ?>
            <figure class="app-icon-figure">
              <img id="app-icon" src="<?= $hero->url() ?>">
            </figure>
          <?php endif ?>

So the image is on the page and I was happy, but now I can’t change the image thru the panel. Can’t delete it or anything. It just stays there.

Now I tried every possible code from the docs and this forum, but nothing helped. I never was able to change or delete the image.

In your template code, $page->image() gets the first image of the page, not the image selected in your hero field. To fetch the image chosen in your field:

 <?php if($hero = $page->hero()->toFile()): ?>
    <figure class="app-icon-figure">
        <img id="app-icon" src="<?= $hero->url() ?>">
    </figure>
<?php endif ?>

$hero = $page->hero()->toFile())

I’m pretty sure I had tried that. Or had I? :nauseated_face: