Can't crop image on upload

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?

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.

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.

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)

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

Because the option is not called template, but uploads: image

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