Form

class markdownx.forms.ImageForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Used for the handling of images uploaded using the editor through AJAX.

clean()[source]

Checks the upload against allowed extensions and maximum size.

Returns:Upload
static get_unique_file_name(file_name)[source]

Generates a universally unique ID using Python UUID and attaches the extension of file name to it.

Parameters:file_name (str) – Name of the uploaded file, including the extension.
Returns:Universally unique ID, ending with the extension extracted from file_name.
Return type:str
save(commit=True)[source]

Saves the uploaded image in the designated location.

If image type is not SVG, a byteIO of image content_type is created and subsequently save; otherwise, the SVG is saved in its existing charset as an image/svg+xml.

Note: The dimension of image files (excluding SVG) are set using PIL.

Parameters:commit (bool) – If True, the file is saved to the disk; otherwise, it is held in the memory.
Returns:An instance of saved image if commit is True, else namedtuple(path, image).
Return type:bool, namedtuple