Skip to content

Commit 3e22b5c

Browse files
authored
Merge pull request #7328 from akatsoulas/upload-type
Restrict upload type
2 parents d32adfe + 3aa9391 commit 3e22b5c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kitsune/upload/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def create_imageattachment(files, user, obj):
3333
Given an uploaded file, a user and an object, it creates an ImageAttachment
3434
owned by `user` and attached to `obj`.
3535
"""
36-
up_file = list(files.values())[0]
36+
up_file = files["image"]
3737
check_file_size(up_file, settings.IMAGE_MAX_FILESIZE)
3838

3939
(up_file, is_animated) = _image_to_png(up_file)
@@ -69,7 +69,9 @@ def _image_to_png(up_file):
6969
# This approach is recommended by pillow for checking if an image is animated.
7070
is_animated = getattr(image, "is_animated", False)
7171

72-
if not is_animated:
72+
if is_animated:
73+
up_file.name = os.path.splitext(up_file.name)[0] + ".gif"
74+
else:
7375
options = {}
7476
if "transparency" in image.info:
7577
options["transparency"] = image.info["transparency"]

0 commit comments

Comments
 (0)