Hello everyone !
I just started my first project with Kirby so I’m a beginner.
http://nicolastilly.fr/ESAD/editionnumerique/
My question is certainly quite simple but yet I do not understand the procedure (doc on the website Kirby is however great!).
My web page contains an image and wish to administer the same way as text fields. How to do?
My image (01.png) is in the “content / 01-home” and the image is clearly visible in the admin left under the tab “FILES”, but how do you make this dynamic image in a field?
Thanks for your help!
The best procedure depends on how you want to use the images:
If you want the user to select a single image, you can use a select field with option “images”:
fields:
my_image:
label: Select an Image
type: select
options: images
http://getkirby.com/docs/cheatsheet/panel-fields/select
You may also want to have a look at the custom selector field by @DieserJonas: https://github.com/storypioneers/kirby-selector
Or at the multi-select field by @distantnative: http://getkirby-plugins.com/multiselect-field
If you just want to get a particular image in your template, let’s say the first image in a page folder:
$image = $page->images()->first();
Thank you @texnixe for your answer.
If you want the user to select a single image, you can use a select field with option “images”:
fields:
my_image:
label: Select an Image
type: select
options: images
Yes it is what I want to do but I do not see what php lines I should add in my page?
<img class="imgiphone" src="http://nicolastilly.fr/ESAD/editionnumerique/content/1-home/01.png" >
It’s not clear in this page : http://getkirby.com/docs/templates/hello-world
To reference the selected image in your template:
<img src="<?php echo $page->image($page->my_image())->url() ?>" >
Thank you for your help , it works!