python - Django easy-thumbnails MAX SIZE -
is there way set max size images uploaded in django app using easy-thumbnails app?
in settings list don't see it.
to cap file size, might want in webserver, rather in django.
alternatively, can specify custom file handler, can raise error if file big:
from django.core.files.uploadhandler import temporaryfileuploadhandler, stopupload class sizelimituploadhandler(temporaryfileuploadhandler): def new_file(self, field_name, file_name, content_type, content_length, charset): if content_length > max_file_size: raise stopupload(true)
though cause connection reset error in order stop processing large file.
if want cap image size, can resize image before saved stated in readme:
by passing
resize_source
argumentthumbnailerimagefield
, can resize source image before saved:
class profile(models.model): user = models.foreignkey('auth.user') avatar = thumbnailerimagefield( upload_to='avatars', resize_source=dict(size=(50, 50), crop='smart'), )
Comments
Post a Comment