views:

31

answers:

1

I'm trying to make it so that the ImageFileField only accepts image files of a set dimension. I found another post on here which suggest hijacking the 'clean' method in a form, but I was wondering if it would be simpler to create a custom field type instead?

Has anyone got any code snippets which I might be able to use in order to do this? I don't want the image files to be resized at all, just uploaded as they are if they are the correct size.

Much appreciated!

+1  A: 

This is a (recent) resizing version of the ImageField form field which sets a max size. You might be able to take inspiration from it for accepting only certain image dimensions (ie, instead of triggering resizing, make the field complain).

http://www.djangosnippets.org/snippets/1966/

Hope that helps

Steve

stevejalim