How to have different Blueprints for images and videos

I’d like to have two different Blueprints for images and video. How would I go about doing this? I don’t want to have to have different Blueprints for png gif jpg jpeg mp4 etc. How would my Blueprint link with the file format/type?

Is it possible to have two Blueprints:

image.yml
video.yml

Both in the site > blueprints > files folder?

And will the Panel automatically know when to use each Blueprint?

I’ve just made a video.yml Blueprint. So I now have the default.yml and video.yml file Blueprints.

In the Panel, when I click on an uploaded video I’m seeing the fields in the default blueprint, not the video blueprint. It appears that Kirby can’t automatically display the video Blueprint?

UPDATE
After more digging around this seems more complicated - for me - than it’s worth. So unless there is a really easy solution, I’m going to leave this.

  1. If you upload a file to a section without specifying a template in the section, no template is assigned to the file and therefore, the default template is used.

  2. If you do assign a template to a section, all uploaded files will get this template, there is no way to assign different templates.

What you can do to work around this limitation:

  1. Do not assign a template to your section.
  2. Assign a template to your files depending on file type via a file.upload:after hook.

Another option:

Use only one blueprint, but show fields in this blueprint conditionally. Use the whenquery plugin to query file types:

Option 1 needs coding skills.

1 Like

Sadly this plugin is no longer listed on the Kirby website. I can find it in github, but not sure if/when it’ll be updated for Kv4.
I may test adding video fields into the default.yml file blueprint and see if that works just fine, too.

Without the plugin, your safest bet is probably to assign the template via a hook after upload.

1 Like

Thanks, Sonja. What’s great about Kirby is that there are so many ways to get what you want.