yes, but i’d like to be able to have .mp4 as covers for my projects. If I cannot connect a template to the /cover.yml file then it just renders the video as text…
Ok, here you use a files section to which you can upload multiple file types and as many files as you want.
You assign a file template called cover.
If this file does not yet exist in the /site/blueprint/files folder, you need to create it.
Then you can limit what sort of files can be uploaded and what sort of fields you want in there etc., see File blueprint | Kirby CMS.
Then in your template, you would fetch the first file with such a template assigned:
<?php if ($file = $project->files()->template("cover")->first()): ?>
<?php if ($file->mime() === 'xyz'): ?>
<!-- do stuff depending on mime type here, or check by extension instead -->
<?php endif ?>
<?php endif ?>
Thank you! However, as i’d like to apply a unique class to each cover via the file/image.yml blueprint, this suggestion doesn’t quite achieve what i’d like. Here’s my code for the file/image.yml blueprint:
title: Image
columns:
main:
width: 1/2
sections:
content:
type: fields
fields:
caption:
label: Caption
type: writer
sidebar:
width: 1/2
sections:
meta:
type: fields
fields:
class:
label: Class
type: text
alt:
label: Alternative Text
type: text
link:
label: Link
type: url
In the project.php template (below) how can I apply this class to the image as well as additional attributes like lazy loading?
Please use the code I provided above instead of echoing the file. Then you need to create the html for the image yourself, which gives you the possibility to add attributes to it.
And you have access to the file object, and thus to every field, .e.g $file->class()