If you’re in the same situation as me, consider a simpler approach as mentioned by texnixe below.
I’ve got the following setup.
This is the parent page and it’s image field:
header_image:
label: Header image
type: image
width: 1/2
Where the user chooses one of the uploaded images.
By default, I want the child pages to use that very same image, unless they have an uploaded image on their own. So my first thought was this:
header_image:
label: Header image
type: select
options: query
query:
page: ../
fetch: files
value: '{{filename}}'
text: '{{filename}}'
width: 1/2
The value is being set just fine - parentimage.jpg
. However I’m struggling with getting the proper url.
The URL for that image should be something like site.com/parent/parentimage.jpg
but the URL I’m actually getting is site.com/parentimage.jpg
.
So, my two questions are:
- How can I get the child
header_image
field to default to the same as it’s parent? Right not it’s empty until manually selected. - Which method should I use in order to get the proper url? I’ve tried a few combinations of
toFile()
andurl()
but so far they’ve come up short.