The users do it because they can.
However, image auto-resize etc. breaks down.
This make me a sad boy.
How to limit image uploads to GIF, PNG and JPEG sitewide?
For Archetypes
For Dexterity
The users do it because they can.
However, image auto-resize etc. breaks down.
This make me a sad boy.
How to limit image uploads to GIF, PNG and JPEG sitewide?
For Archetypes
For Dexterity
Using Archetypes you override the image content class or create your own custom image content class with the following schema.
You can just add the line
allowable_content_types = ('image/gif', 'image/jpeg', 'image/png'),
to your schema
ie
MyImageSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((
ImageField('image',
required = False,
allowable_content_types = ('image/gif', 'image/jpeg', 'image/png'),
storage=AttributeStorage(),
sizes= {'large' : (768, 768),
'preview' : (400, 400),
'mini' : (200, 200),
'thumb' : (128, 128),
'tile' : (64, 64),
'icon' : (32, 32),
'listing' : (16, 16),
},
widget = ImageWidget(
label=_(u"Image"),
show_content_type=False,
),
),
I would probably use a schema extender to extend the Image class, overriding that particular field
i ran into similar problems these days and worked around them like that:
accept
attribute to the file inputfield.swallowResizeExceptions = True
so users at least don't get a site-error when uploading an unsopported image typeThe field definition looks like this:
note that
accept="image/jpeg,image/gif"
was ignored by firefox11 although it sould be supported according to http://www.w3schools.com/tags/att_input_accept.aspmywidgets/myimage is a customized version of archetypes/skins/widgets/image.pt that uses a customized version of archetypes/skins/widgets/file.pt
and mywidgets/myfile.pt simply defines this macro: