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?
texnixe
February 24, 2021, 1:15pm
2
Yes, xou can filter them by the template you attach via this section
$page->images()->template('image')->sortBy('sort', 'filename');
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:
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
texnixe
February 24, 2021, 6:52pm
4
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.
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
texnixe
February 25, 2021, 8:49pm
6
If moodboard is a files field (instead of a section), then you have to set the upload property, not a template property.
Great - that worked. Thank you for your patience