Recipe for limiting object size
for files, images, documents; from Kurt Bendl
We'd talked about image size issues a couple of weeks ago.
There are two ways to get what you want, either use an egg
and add a part to your buildout, or copy the file to
client/etc/atcontenttypes.conf and edit it.
Egg: plone.recipe.atcontenttypes
===========================================
Here's an recipe that'll setup the config:
http://pypi.python.org/pypi/plone.recipe.atcontenttypes/
Add a atcontenttypes-conf part to your buildout, plus
the config:
parts =
plone
zope2
productdistros
zeoserver
client1
client2
zopepy
zopeskel
precompile
chown
unifiedinstaller
fss
atcontenttypes-conf
# And the part configs
[atcontenttypes-conf]
max-image-dimension =
ATNewsItem:640,400
ATImage:1024,1024
max-file-size =
ATImage:1mb
ATNewsItem:500kb
# ATFile:100mb
Copying the file
===========================================================
The config is based on this file:
parts/plone/ATContentTypes/etc/atcontenttypes.conf.in
You can copy this file as 'atcontenttypes.conf' into the
same dirs as the 'client{1,2}/etc/zope.conf' files. and
make the modifications needed to max-image-dimension and
max-file-size for ATImage. Something like the following:
max-image-dimension =
ATNewsItem:100,150
ATImage:1024,1024
max-file-size =
ATImage:1mb
ATNewsItem:500kb
The stanza will look like this:
<archetype ATImage>
# maximum file size in byte, kb or mb
max_file_size no
# maximum image dimension (w, h)
# 0,0 means no rescaling of the original image
max_image_dimension 0,0
</archetype>
# Change what you need to change.......
# ----------------------------------------
#Change the new copy to something like:
<archetype ATImage>
max_file_size 1mb
max_image_dimension 1024,1024
</archetype>
#And do something similar to news items if you wish.
<archetype ATNewsItem>
max_file_size 500k
max_image_dimension 100,125
# enable upload of documents
allow_document_upload yes
<contenttypes>
default text/html
allowed text/structured
allowed text/x-rst
allowed text/html
allowed text/plain
</contenttypes>
</archetype>











