Updating an image in the Panel doesn't update the image on frontend

I have events, these have an image. When the event is created, the image is saved and shown.
But when I change the image from this event to another image, the previous image will still be shown on the frontend. The image in the panel is changed.

So the panel is oke but the image in the frontend is not changing. The text and other fields (date) can be changed without problem.
If I delete the image, also the old image will still be shown on the frontend. In the panel it’s deleted.

I deleted the cache in site\cache. No change, the image is still shown.
In the content\events\ folder the image is changed (or deleted) the same as in the panel.

On the frontend the image is got from the ‘wrong’ place: <img class="extra-flets" width="550px" src="https://cafedeburcht.eu/media/pages/activiteiten/djleed-sizzer/3efea1e8a9-1684764626/foto-dj-leedsizzer-disco.jpg" alt="">

Where activiteiten is the events.

I have altered the template. I deleted the crop line, but that changed nothing. After deleting the crop command from the template, I could change the image on the frontend. Once. The second time it wouldn’t change anymore.

<?php  /* $plaatje = $plaatje->crop(550,420) */?> 
<img class="extra-flets" width="550px" src="<?= $plaatje->url()?>" alt="<?= $plaatje->alt()->esc() ?>">

it looks like a cache problem, but I deleted the cache in site/cache.

Question
What could be the cause of the image not changing on the frontend?
What can I investigate more?

(if you need the blueprint and template for this, please say so)
(Kirby 3.9.2)

Thanks!
René

I found the problem. I used $page->image() in stead of $page->image()->toFile() in my template.

event.php template old code

<?php if ($plaatje = $page->image()): ?>
<img class="extra-flets" width="550px" src="<?= $plaatje->url()?>" alt="<?= $plaatje->alt()->esc() ?>">

somehow using $page->image() would show an image on the frontend. But after changing the image in the panel, it wouldn’t show the change. Maybe using an image field with the name ‘image’ is not a good idea.
changes

  1. so I changed the field name (in the blueprint) from ‘image’ to ‘afbeelding’.
  2. and I found the correct syntax and added ->toFile() to the code.

event.php template new code

<?php if ($plaatje = $page->afbeelding()->toFile()): ?>
<img class="extra-flets" width="550px" src="<?= $plaatje->url()?>" alt="<?= $plaatje->alt()->esc() ?>">

I went through the content files to alter the fieldname from ‘Image:’ to ‘Afbeelding:’ and all was fixed.

I’m still not sure why originally the image was shown and was not changeable. But I’m glad I found and fixed it.

René

Right, $page->image() returns the first image Kirby finds. If that is a field, you have to use $page->content()->image(). See naming fields: Fields | Kirby CMS

1 Like