Resize on upload as page option

Hello. I’ve seen plugins that allow you to set a max-size upon the user uploading to any/every page within the panel, but is anything available that would allow the max-size to be set per template? It’s very common to have an extra large image on the home page for a hero graphic, but only need say 800 px width images for pretty much every other page. Thoughts?

You can limit the size of images that can be uploaded via your blueprints using the size option:

    size: 12000000

Thanks for the reply.

Isn’t that file size? I’m referring to dimensions.

Consider the average client. They find the image they want. They do not know what file size or width or height it is. They’re just glad they got this far and now they want to dump this massively large file into the CMS to be used on the page. We can resize at the template level but I don’t want these massive files sitting on the server takin’ up my SSD space (which isn’t cheap). If a client gets hit with an error stating that the file size is too large they just call me.

I think a valuable feature would be to allow the dev to set a max-width and/or height to uploaded images. This would be set at the blueprint just like ‘size’ is. And as extra credit perhaps do this on client-side. Consider this for clarity.

Ok, that wasn’t clear from your first post, but just underneath the size there is also an width and height option.

Apart from that, you could of course use a hook to auto-resize images on the server side.

As regards server-side resizing, you could create a feature request in the Panel repo.

Right. “max-size” didn’t help matters. I never got into exploring hooks and such. I suppose I should.

I was referring to this option:

    width: 500
    height: 300

Doesn’t it work?

Does this resize the file on upload?

Or does it just throw an error if it’s not, say 500 x 300?

No, it just throws an error.

As I said, if you want to resize images, you would have to use a hook, if you use an if statement inside that hook, you can do different things depending on template.

See this solution:

As always, thanks for the useful info Sonja. I’ll review this further.