Panel: Show Thumb from specific field

I’d like to display specific image field as a thumbnail for pages in the panel.

The image is defined like this:

  label: Hero Image
  type: files
  max: 1

And this is the definition there I want to query the heroimage:

    type: pages
      en: Pages
      de: Seiten
    layout: cards
    status: listed
      query: page.images.findBy("name", "heroimage").last
      cover: true
      ratio: 16/9

This query is wrong, I know. But how can I get the heroimage?

I’d use a page model

  query: page.heroimage

Define page model for you page type, see /site/models/album.php example in the Starterkit.

The same is done in the Starterkit for the album pages, queried as page.cover in /site/blueprints/sections/albums.yml.

1 Like

Ah, page models. Now I got it. Thank you very much.

If a page model is not good enough because you want to use this for multiple page types, you can also create a custom page method.