File Selector not updating image->url() based on the selected file for images

Why does the file selector for images always update the source with the latest uploaded image instead of changing the$image->url() to reflect the image selected in the panel?

For example, if I upload “Image A,” the blueprint will update to:
Image: - file://imageA-Uuid123
Then, if I upload “Image B,” the blueprint will change to:
Image: - file://imageB-Uuid123
However, if I go back and select “Image A” from the panel, the blueprint ID updates in the text file, but in the frontend only loads the last uploaded image url.

here is a overview:

my pages blueprint

title: Title Text Card
fields:
  titleMain:
    label: Title
    type: text
  text:
    label: Text
    type: textarea
  image:
    label: Image
    type: files
    multiple: false
    max: 1
    width: 1/3

my text file of the edited page

Title: test 123

----

Titlemain: 

----

Text: 

----

Image: - file://lR2rbpXFD3ernzPy

and so i try to read the selected image

    $pages = $page->children()->filterBy('intendedTemplate', 'titletextcard');
    foreach ( $pages as $subpage):
        $title = $subpage->titleMain()->toString();
        $text = $subpage->text()->toString();
        $image = $subpage->Image();
        echo $image->url();

the image Uuid updates when selecting a new image, but the data returned from $image variable is always the last uploaded image

as you can see it has 2 “siblings” and these are the available files in the selector,

but the content Uuid never changes in the data, until i upload a newer image

 object(Kirby\Cms\File)#365 (22) {
  ["content"]=>
  object(Kirby\Content\Content)#367 (1) {
    ["uuid"]=>
    string(16) "x0eZIUJbovHFJzKr"
  }
  ["translations"]=>
  array(0) {
  }
  ["dimensions"]=>
  array(4) {
    ["width"]=>
    int(1280)
    ["height"]=>
    int(853)
    ["ratio"]=>
    float(1.5005861664712778)
    ["orientation"]=>
    string(9) "landscape"
  }
  ["exif"]=>
  array(8) {
    ["camera"]=>
    array(2) {
      ["make"]=>
      NULL
      ["model"]=>
      NULL
    }
    ["location"]=>
    array(2) {
      ["lat"]=>
      NULL
      ["lng"]=>
      NULL
    }
    ["timestamp"]=>
    string(10) "1726738232"
    ["exposure"]=>
    NULL
    ["aperture"]=>
    NULL
    ["iso"]=>
    NULL
    ["focalLength"]=>
    NULL
    ["isColor"]=>
    bool(true)
  }
  ["extension"]=>
  string(3) "jpg"
  ["filename"]=>
  string(20) "cat-8198720_1280.jpg"
  ["hash"]=>
  string(32) "7b1daef2455c2b5df97d0d25c8d29a6f"
  ["isReadable"]=>
  bool(true)
  ["isResizable"]=>
  bool(true)
  ["isWritable"]=>
  bool(true)
  ["mime"]=>
  string(10) "image/jpeg"
  ["modified"]=>
  string(25) "2024-09-19T11:30:32+02:00"
  ["name"]=>
  string(16) "cat-8198720_1280"
  ["niceSize"]=>
  string(10) "124.04 KB"
  ["root"]=>
  string(124) "/var/customers/webs/webpixel/temp/customer/website.com/content/2_ausstellungen/1_termine/cat-8198720_1280.jpg"
  ["safeName"]=>
  string(16) "cat-8198720_1280"
  ["size"]=>
  int(127019)
  ["type"]=>
  string(5) "image"
  ["url"]=>
  string(111) "https://website.com/media/pages/ausstellungen/termine/4aaf5aaee7-1726738232/cat-8198720_1280.jpg"
  ["id"]=>
  string(42) "ausstellungen/termine/cat-8198720_1280.jpg"
  ["template"]=>
  NULL
  ["siblings"]=>
  object(Kirby\Cms\Files)#364 (2) {
    [0]=>
    string(42) "ausstellungen/termine/cat-8198720_1280.jpg"
    [1]=>
    string(45) "ausstellungen/termine/insect-8211593_1920.jpg"
  }
}

here is an image of the file Uuids as you can see the right Uuid is selected but the data never changes in frontend

what am i doing wrong ? Thanks

This is not calling on your image field, but the $page->image() method: $page->image() | Kirby CMS

Calling it without any filename, it will return the first image of the page. That’s why you get different results after uploading new images.

For your use case, you should rename the field to something else than image, e.g. cover, poster

And then in your template you need to do something like (considering the field name is cover):

if ($image = $page->cover()->toFile()) {
echo $image->url();
}
1 Like

True, i renamed the field to a custom name like “customImage” and then called it using
$subPage->customImage->toFile(), took me a while to realize that there could be controdictions with naming blueprint fields that kirby is already using as methods.