# Pulling the gallery media from specific field

**URL:** <https://forum.getkirby.com/t/pulling-the-gallery-media-from-specific-field/21340>\
**Category:** Questions\
**Tags:** v3\
**Created:** [February 24, 2021, 1:10pm UTC](https://forum.getkirby.com/t/pulling-the-gallery-media-from-specific-field/21340 "2021-02-24T13:10:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![denkstream](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/denkstream/32/6628_2.png) [@denkstream](https://forum.getkirby.com/u/denkstream)\
**Post date:** [February 24, 2021, 1:10pm UTC](https://forum.getkirby.com/t/pulling-the-gallery-media-from-specific-field/21340/1 "2021-02-24T13:10:50Z")

</div>

For my album template I got the same controller like in starterkit:

```
<?php
return function ($page) {
    $gallery = $page->images()->sortBy('sort', 'filename');
    return [
        'gallery' => $gallery
    ];
};

```

in my album template i got this section (moodboard):

```
        moodboard:
          label: Moodboard
          type: files
          layout: cards
          template: image
          info: "{{ file.dimensions }}"
          image:
            ratio: 5/4
            cover: true
          size: small

```

Is there a way to specificaly configure album controller to pull only files defined by “moodboard” and not all images uploaded in that folder? 🙂

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 24, 2021, 1:15pm UTC](https://forum.getkirby.com/t/pulling-the-gallery-media-from-specific-field/21340/2 "2021-02-24T13:15:54Z")

</div>

Yes, xou can filter them by the template you attach via this section

```auto
$page->images()->template('image')->sortBy('sort', 'filename');

```

---

<div class="post-metadata">

**Author:** ![denkstream](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/denkstream/32/6628_2.png) [@denkstream](https://forum.getkirby.com/u/denkstream)\
**Post date:** [February 24, 2021, 6:37pm UTC](https://forum.getkirby.com/t/pulling-the-gallery-media-from-specific-field/21340/3 "2021-02-24T18:37:14Z")

</div>

Hey texnixe - thanks!

now I have this situation, that media isn’t shown when uploaded to moodboard field. I’ve got this message when showing files uploaded to moodboard:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/f/faab02bd6e57e34545cbee4c7ed69c9b701e8d9f.png)

This is my setup:  
I’ve modified the section of album template to this (added template moodboard) to differentiate to another part of blueprint where cover image is uploaded. Moodboard is a gallery.

```
blueprint/pages/album.yml
....
moodboard:
 label: Moodboard
 type: files
 layout: cards
 template: moodboard
 info: "{{ file.dimensions }}"
 image:
 ratio: 5/4
 cover: true
 size: small

```

and I created a moodboard file template:

```
blueprint/files/moodboard.yml
....
title: Moodboard

accept: 
  type: image

columns:
  - width: 1/2
    sections:
      content:
        type: fields
        fields:
          caption:
            label: Caption
            type: textarea
            size: medium
  - width: 1/2
    sections:
      meta:
        type: fields
        fields:
          alt:
            label: Alternative Text
            type: text

```

And album controller is the same like You adviced to do 🙂

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 24, 2021, 6:52pm UTC](https://forum.getkirby.com/t/pulling-the-gallery-media-from-specific-field/21340/4 "2021-02-24T18:52:47Z")

</div>

If you change the file template mid-way in the section, the files will not automatically update. So you have to either manually change the template in your file meta data, or programmatically.

---

<div class="post-metadata">

**Author:** ![denkstream](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/denkstream/32/6628_2.png) [@denkstream](https://forum.getkirby.com/u/denkstream)\
**Post date:** [February 25, 2021, 6:16pm UTC](https://forum.getkirby.com/t/pulling-the-gallery-media-from-specific-field/21340/5 "2021-02-25T18:16:40Z")

</div>

I added completely new project, somehow it doesn’t register that it should use moodboard file template when uploading the file to that field?

In my album blueprint template I got two file sections and this setup:

```
album.yml file sections:
...
moodboard:
  headline: Moodboard
  type: files
  layout: cards
  template: moodboard
  info: "{{ file.dimensions }}"
  image:
    ratio: 5/4
    cover: true
  size: small
cover:
  headline: Cover
  type: files
  layout: cards
  template: cover
  info: "{{ file.dimensions }}"
  max: 1

```

* * *

```
blueprint/files/moodboard.yml:
...
title: Moodboard
accept: 
  type: image
columns:
  - width: 1/2
    sections:
      content:
        type: fields
        fields:
          caption:
            label: Caption
            type: textarea
            size: medium
  - width: 1/2
    sections:
      meta:
        type: fields
        fields:
          alt:
            label: Alternative Text
            type: text

```

* * *

```
blueprint/files/cover.yml:
...
title: Image
accept: 
  type: image
columns:
  - width: 1/2
    sections:
      content:
        type: fields
        fields:
          caption:
            label: Caption
            type: textarea
            size: medium
  - width: 1/2
    sections:
      meta:
        type: fields
        fields:
          alt:
            label: Alternative Text
            type: text
          photographer:
            label: Photogapher
            type: text
            width: 2/3
          license:
            label: License
            type: select
            width: 1/3
            options:
              - Unsplash
              - CC BY 4.0
              - CC BY-SA 4.0
              - CC BY-NC 4.0
              - CC BY-ND 4.0
          link:
            label: Link
            type: url
```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 25, 2021, 8:49pm UTC](https://forum.getkirby.com/t/pulling-the-gallery-media-from-specific-field/21340/6 "2021-02-25T20:49:22Z")

</div>

If moodboard is a files field (instead of a section), then you have to set the upload property, not a template property.

> **[Files](https://getkirby.com/docs/reference/panel/fields/files#upload-options)**
>
> A files select field that allows to select one or multiple related files

---

<div class="post-metadata">

**Author:** ![denkstream](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/denkstream/32/6628_2.png) [@denkstream](https://forum.getkirby.com/u/denkstream)\
**Post date:** [February 26, 2021, 7:38am UTC](https://forum.getkirby.com/t/pulling-the-gallery-media-from-specific-field/21340/7 "2021-02-26T07:38:42Z")

</div>

Great - that worked. Thank you for your patience 🙂
