Add animated profile picture support
This commit is contained in:
parent
72c004cb56
commit
82924c999a
2 changed files with 36 additions and 12 deletions
|
|
@ -271,9 +271,17 @@ class PictureUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, FormMixin, Det
|
|||
|
||||
def form_valid(self, form):
|
||||
"""Save image to note"""
|
||||
image_field = form.cleaned_data['image']
|
||||
image_field.name = "{}_pic.png".format(self.object.note.pk)
|
||||
self.object.note.display_image = image_field
|
||||
image = form.cleaned_data['image']
|
||||
|
||||
# Rename as a PNG or GIF
|
||||
extension = image.name.split(".")[-1]
|
||||
if extension == "gif":
|
||||
image.name = "{}_pic.gif".format(self.object.note.pk)
|
||||
else:
|
||||
image.name = "{}_pic.png".format(self.object.note.pk)
|
||||
|
||||
# Save
|
||||
self.object.note.display_image = image
|
||||
self.object.note.save()
|
||||
return super().form_valid(form)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue