Kirby headless cms with files blocks get real urls?

Hi,

is there any easy solution to use files blocks while using kirby as headless cms? A few month ago the i could build a block exporter (there was a tutorial with how to generate a json file) an get at least the file name out of an image. Which was ok combined with the url of the block post.
Today i just can get a cryptic hash value… I guess its great if kirby is used a cms with pure php. But in my case it is really a pain. For better understanding:

I want to use Kirby for some kind of Webapp and build a kind of database with materials. To get the data i build a custom json template (which is faster than using the api)

<?php

$materialsInput = $pages->template("materials");
$materialsOutput = [];

foreach ($materialsInput->children() as $entry) {

  $sub = array(
    "headline" => $entry->headline()->value(),
    "subline" => $entry->subline()->value(),
    "json" => json_decode($entry->json()),
    "blocks" => json_decode($entry->text())
  );

  array_push($materialsOutput, $sub);

}
echo json_encode($materialsOutput, JSON_HEX_QUOT | JSON_HEX_TAG);

cool that was a pretty easy template. But if i use image blocks i wont get the real url, but some kind of?:

{
...
"content": {
  "images": [
    "file://PC6r3uU7P1JJK1a4",
    "file://HEZWeQzqkspijRK5",
    "file://V3KL7PspVYxydxI0",
    "file://vpqvSwjFKRds8Omu"
  ],
  "caption": "",
  "ratio": "",
  "crop": "false"
},
"id": "39f8122b-7e52-4b78-a71a-565d8025aeb3",
"isHidden": false,
"type": "gallery"
},
....

so ist it possible to get real urls, whitout building a kind of extra logic to parse all image blocks? otherwise kirby (which was so far really one of the best cms i have worked with) would become a little bit useless.

I htink the easiest way would be to parse those UUIDS a little client-side to create permanent urls, which have this format:

https://example.com/@/page/hb38HvnQfm8HlQ6e
htttps://example.com/@/file/PC6r3uU7P1JJK1a4

See Unique IDs & Permalinks | Kirby CMS

1 Like

Thanks for the quick help, this should work. I just downgraded to a prior verison for now, to avoid the overhead to make a request for every file. Maybe the uuids will be possible to disable in the 3.8.1 verions as mentioned here.

The files, users and pages field still allow you to store the id (behavior before 3.8) instead of the UUID via the store property, so you would not have to wait until UUIDs can be disabled.

You would have to edit the blueprints for the gallery/image blocks though.