Mark_E
April 26, 2024, 4:02pm
1
I’d like to prevent client from uploading files with massive dimensions to the Contents folder. I’m trying to follow the instructions here to optimize uploaded images (File blueprint | Kirby CMS )
This is the code in this file: site/blueprints/files/image.yml
title: Image
create:
width: 500
height: 500
crop: true
and this is my Blueprint code:
title: Workshop weekly
columns:
main:
width: 2/3
fields:
hero_image:
label: Hero image
type: files
multiple: false
But the uploaded images in the Contents folder are keeping their original dimensions.
What’s going on?
Also, will uploaded images get cropped to a 500px square?? Or will the largest dimension get reduced to 500px and the aspect ratio will be kept?
stffr
April 26, 2024, 4:07pm
2
Mark_E:
What’s going on?
Your file blueprint has the image
template, but your hero_image
field has no template assigned on upload. You have to either rename site/blueprints/files/image.yml
to default.yml
or add template: image
to your hero_image
field
It will be resized to the maximum of 500px on the longer side. It won’t be cropped.
Mark_E
April 26, 2024, 4:14pm
3
Thanks!
I’ve now got the following in my Blueprint
title: Workshop weekly
columns:
main:
width: 2/3
fields:
hero_image:
label: Hero image
type: files
template: image
multiple: false
But new uploaded images are still not being resized. Any ideas?
I trust smaller images won’t be enlarged to 500px? I’d test it out if I could.
Mark_E
April 26, 2024, 4:31pm
4
I’ve now tried renaming site/blueprints/files/image.yml
to default.yml
and new uploaded images are being resized…
but they are being resized and cropped to 500px squares.
and I don’t really want to use default.yml (I’ll probably need a few image templates)
Mark_E
April 26, 2024, 4:36pm
5
Okay… removing crop: true works
title: Image
create:
width: 500
height: 500
So the next thing is creating a file blueprint template called hero_image and assigning it in my page blueprint. Which I can’t get to work
Mark_E:
template: image
Because the option is not called template, but uploads: image
Mark_E
April 26, 2024, 4:49pm
7
Found this post Image template for files to only accept images doesn't work
A files field doesn’t have a “direct” template option, the template is set under the upload option:
gallery:
type: files
uploads:
parent: site
template: files-upload
That works, but I don’t know what the parent:site does?
It’s all in the documentation: Files | Kirby CMS