mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Fixed #24948 -- Fixed crash when uploading bitmap images in forms.ImageField
This commit is contained in:
committed by
Tim Graham
parent
fbc618c13c
commit
cf6ce279c7
@@ -683,7 +683,9 @@ class ImageField(FileField):
|
||||
|
||||
# Annotating so subclasses can reuse it for their own validation
|
||||
f.image = image
|
||||
f.content_type = Image.MIME[image.format]
|
||||
# Pillow doesn't detect the MIME type of all formats. In those
|
||||
# cases, content_type will be None.
|
||||
f.content_type = Image.MIME.get(image.format)
|
||||
except Exception:
|
||||
# Pillow doesn't recognize it as an image.
|
||||
six.reraise(ValidationError, ValidationError(
|
||||
|
||||
Reference in New Issue
Block a user