Skip to content

Instantly share code, notes, and snippets.

View gassan's full-sized avatar

Gassan Gousseinov gassan

  • Marburg, Germany
View GitHub Profile
from wagtail.images.forms import BaseImageForm
from .image_utils import resize
class ImageForm(BaseImageForm):
# store user in __init__ and set default position of watermark
def __init__(self, data=None, files=None, **kwargs):
file = files and files.get('file', None)
already_resized = kwargs.pop('already_resized', False)
if not already_resized and file:
new_file = resize(file, file.field_name, file.name, file.content_type)