Can't apply file blueprint for images

I’m a little stuck with a new blueprint for images. Currently I have my default image blueprint, which looks like this:

title: Media Editor

create:
  width: 1200
  crop: false
  format: webp
  
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
          loading:
            width: 1/2
            label: Loading
            type: select
            options:
              lazy : lazy
              eager: eager
          class:
            width: 1/2
            label: CSS Class
            type: text

It works well and formats any images I upload to webp and makes them 1200px. All good.

However, I have a need to occasionally upload other files, in which case they’re also converted to webp and shrunk to 1200px. Not good.

So I created /site/blueprints/files/image.yml and moved the create option into there. I also updated my page blueprint from to this:

uploads:
            label: Uploads
            type: files
            template:
              - image
            accept:
              - image/*
            layout: cards
            limit: 4

But image processing is no longer working and my image.yml blueprint is being ignored. Clearly I’m doing something wrong here, but the documentation has me confused as to what I need to do.

Any help would be appreciated.

Thanks,

Kev

There is no accept option as property of a files section, the accept prop belong inside the file blueprint.

Yeah I know. That snippet is from one of my page blueprints. To be more clear, here’s the entire blueprints:

/site/blueprints/files/image.yml

title: Image Editor

create:
  width: 1200
  crop: false
  format: webp
  
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
          loading:
            width: 1/2
            label: Loading
            type: select
            options:
              lazy : lazy
              eager: eager
          class:
            width: 1/2
            label: CSS Class
            type: text

/site/blueprints/pages/note.yml

title: Notes
icon: draft

create:
  title: "{{ site.pretty-time }}"
  slug: "{{ site.time }}"

columns:
  main:
    width: 2/3
    sections:
      fields:
        type: fields
        fields:
          text:
            type: textarea
            size: medium
            maxlength: 500
          uploads:
            label: Uploads
            accept:
                - image/*
            type: files
            layout: cards
            limit: 4

  sidebar:
    width: 1/3
    sticky: true
    sections:
      meta:
        type: fields
        fields:
          published:
            label: Published Date
            type: date
            display: DD MMMM YYYY
            time: true
            default: now

It’s still applying the default template though.

This is different from what you originall posted above. Here you do not assign a template at all via the uploads property, see Files | Kirby CMS. And again, accept is not a valid property of the field, this accept prop needs to go into the files blueprint to take effect.

Sorry for confusing things. My blueprints change as I’m troubleshooting the issue.

I think I’m confusing myself here and that’s where the problem is. So what I’m trying to achieve is being able to upload images or videos and have the processing applied to the images, but not the videos.

I (wrongly it seems) assumed that by creating an image blueprint, that would apply to images and anything else would hit the default because there’s no blueprint defined.

So if I need to define a template in the file blueprint too, would I need 2 fields to achieve this, 1 for images and another for videos?

Thanks.

Yes, if you want to assign different file blueprints, you need different fields/section. An alternative would be to assign blueprints based on type via a file.create:after hook.

Riiiight that makes more sense now. Thanks!