We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2d586b2 commit 4cc3ef5Copy full SHA for 4cc3ef5
apps/html_template_editor/validators.py
@@ -7,11 +7,19 @@
7
def validate_logo_image(image):
8
max_width = 300
9
megabyte_limit = 5.0 * 1024 * 1024
10
+ allowed_image_formats = ['JPEG', 'PNG']
11
- width, height = Image.open(image).size
12
+ img = Image.open(image)
13
+ width, height = img.size
14
image_file_size = image.tell()
15
+ image_file_format = img.format
16
+
17
+ if image_file_format not in allowed_image_formats:
18
+ raise ValidationError(
19
+ _("Allowed image format is %(image_formats)s "),
20
+ params={'image_formats': ', '.join(allowed_image_formats)},
21
+ )
22
- print(width, image_file_size)
23
if width > max_width:
24
raise ValidationError(
25
_("Width is larger than what is allowed %(max_width)s px"),
0 commit comments