How can I set what image is used in a page section blueprint ? I have a thumbnail field that I would like to show on the parent panel page.
You have to return an image object, so page.field.toFile()
should do the job.
Is this what you mean? My file section is called “listing” in project.yml
published:
headline: Published Projects
type: pages
status: listed
layout: cards
size: medium
image:
query: page.listing.toFile()
ratio: 1/1
info: "{{ page.sum }}"
templates:
- project
That’s what I meant
It does not work for me, I also tried:
query: page.images.filterBy('template', 'listing-thumb').toFile()
That doesn’t make sense, but query: page.listing.toFile()
should definitely work. If your field name is correct.
Have you cleared the browser cache?
is is because I am using a file section, not a file field?
#project.yml
sections:
listing:
headline: Work image
help: Shown on the main work page.
type: files
layout: cards
size: small
template: listing-thumb
image:
ratio: 1/1
max: 1
Ah, yes, a files section doesn’t store anything, so you can’t turn that into a file object with the toFile()
method. And you can’t query it from listings
since that is not a field.
Then this should work:
query: page.images.findBy('template', 'listing-thumb')
yeah, that’s the one! nice one.