When you create that page, what is stored in the content file before you open the page in the Panel? I don’t think it makes sense to store a Unix timestamp, given that the Panel stores a date in the format YYYY-mm-dd and probably doesn’t make sense of the timestamp (not tested).
If it works with another field name, then I assume it interferes with the native image method, but would have to check what happens in the source code.
I also want to create a page programmatically and want to add an image from the assets. But I dont know what to write instead of your $image? What is behind this variable? How do I refer to an image from the assets?
What exactly do you want to achieve? In the example, only a reference to an image is stored in a field, but not actually a file moved into the files folder.
So under specific circumstances I want to create a child of a page programmatically – that is working well so far. But in this specific case I also want to pre-fill the text (what is working) and image fields.
I want to do that, because the page should be online/visible as soon as the page is created and for that I need an image (because of the layout/design). At the moment the page is created but I first need to add an image via the panel. And I want to pre-fill it, and later you still can change the image via the panel.
The text is easy. But how do I add there an image from the assets folder? I thought I could do it like this or so "teaser_image" => "assets/img/image_name.jpg"
If you want to store something in a files field, the file must actually exist in the content folder, so you would have to move it there from the assets folder. Also, a files field expects that you store the data yaml-encoded.
The alternative would be to not store anything in that field, and only fall back to the image from the assets folder in your template. I think that’s probably the better option.
Ah ok, I kind of thought about that, but I also dont know how to add the file to that content folder. Do you have an example code or a reference to a tutorial? Sorry I am a total beginner in Kirby.
Its a special case, so I dont want to have that image as a default in the blueprint