I use the KQL plugin to get data from a JSON. When I query blocks, I don’t see the URL from an image blocks. How to get the image url?
The equivalent in PHP to :
<?php if ($image = $block->image()->toFile()): ?>
<?= $image->url() ?>
<?php endif; ?>
This is what my JSON file return from the image block (“Kirby” location selected) :
I also have the same question. I use kirby headless so I would like to get the file url.
Is there a way to change what the image block returns?
I think one way would be to write my custom block ( Creating a custom block type from scratch | Kirby CMS) where I define that return values should include the fill image path (also giving me the power to resize and crop the images how I want).
But if I could just override and customize the default image block type, that would be even better…
Thanks for any thoughts about that idea.
Yeah but that did not do it. (Well, the link does at least not explain how to do that.) I needed to update some fields on the update hook.
The solution is discussed in depth here:
Thanks a lot for looking into this and for the help.
As for a kirby noob like me this answer is not fully complete, I post my code here to maybe help someone in the future:
A prerequisite for this to work is, that you override the image.yml:
and add a url property only then it can be set.
Also the part of how to convert it to an array is missing. As I did not know there is a kirby method for that I needed to find out first:
// we dont ne…
So yeah, in the end I used the default image block and saved the full path programmatically.
But thanks for getting back to me.