Kirby 5 not displaying images

I have updated to Kirby 5. But forgot to delete the media folder (Install & update via download | Kirby CMS)

On my local set up, I visited the homepage and some of the images are not displaying. I then deleted the media folder and cleared my browser history, but the images are still not displaying. The images are in my home content folder. On first glance, other pages and images display fine.

My backup is also displaying fine. Why would the images in my home contents folder not display? These images are also not appearing in the media folder.

An example. Code from home.php template:

<img src="<?= url('/home/example.svg') ?>">

Is this because I forgot to delete the Media folder before looking at the homepage? Or in Kirby 5 can we not use the title ‘home’?

Turns out my code is wrong (it’s worked in Kirby 3 and 4 but not in 5).

Is this the correct way?


<img src="<?= $page->file('example.svg')?->url() ?>" alt="">

Hey,
I am running into a similar issue after upgrading from 4.8 to 5.0.
All content images in frontend are broken but panel displays fine.

For example I am trying to display an image from a defined news blueprint.
In v4 and v5 this returns a filepath relative to “media/pages/” but displays the images only in v4:

<img src="/<?= $page->imagenews()->toFiles() ?>">

According to the docs I changed to the following, which returns some kind of identifier like “file://850teZN2yZme1qrz“. This version is not displaying the image in v4 and v5:

<img src="/<?= $page->imagenews()->url() ?>">

The definition in blueprint looks like this:

[...]
fields:
  imagenews:
    label: select image
    type: files
    multiple: false
    max: 1
    layout: cards

Any hint of what I don’t get?

@Mark_E the “→url()” is working for you?

Greetings Tim

You will need both:

  • turning your stored content value into a file object via ->toFile() (not plural, if you only want one)
  • calling the ->url() method on your file object

Best to wrap this in an if-clause:

<?php if ($image = $page->imagenews()->toFile(): ?>
<img src="<?= $$image->url() ?>">
<?php endif ?>

Awesome, that’s it!
Thanks a lot!!!