hi,
Each portfolio project on my website have a media gallery where I would like to upload both videos and images.
To give each file type it’s own template I am using the file.create:after
hook to assign the appropriate template based on the file type.
The hook does not seem to work at all, and I am now stuck with no idea what would be wrong.
Any help or pointers in the right direction is greatly appreciated!!
site/config.php:
'hooks' => [
'file.create:after' => function ($file) {
foreach (kirby()->languages() as $lang) {
if ($file->type() === 'image') {
$file->update([
'template' => 'image'
], $lang->code() );
} elseif ($file->type() === 'video') {
$file->update([
'template' => 'video'
], $lang->code() );
}
}
}
]
Project.yml blueprint ( I am uploading the mixed media through the mediaGallery )
#
# Single project page blueprint.
title: Project
status:
draft: Draft
unlisted: Unlisted
listed: Published
columns:
media:
- width: 1/2
sections:
mediaGallery:
type: files
layout: cards
label:
en: Photos
dk: Fotos
size: tiny
information:
- width: 1/2
fields:
tags:
type: tags
label: Categories
min: 1
accept: options
options:
- food
- design
- interior
- cosmetics
- film
- portrait
description:
type: textarea
size: small
credits:
label: Credit list
type: structure
fields:
name:
label: name
type: text
role:
label: role
type: select
options:
makeup: Makeup
hair: Hair
styling: Styling
talent: Talent
link:
label: link
type: url