mirror of
https://github.com/Hopiu/django-markdownx.git
synced 2026-05-01 18:14:43 +00:00
commit
eb6d980231
1 changed files with 4 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ import uuid
|
|||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.utils.six import StringIO
|
||||
from django.utils.six import BytesIO
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.files.uploadedfile import InMemoryUploadedFile
|
||||
from django.template import defaultfilters as filters
|
||||
|
|
@ -24,11 +24,12 @@ class ImageForm(forms.Form):
|
|||
|
||||
def save(self, commit=True):
|
||||
img = scale_and_crop(self.files['image'], **MARKDOWNX_IMAGE_MAX_SIZE)
|
||||
thumb_io = StringIO()
|
||||
thumb_io = BytesIO()
|
||||
img.save(thumb_io, self.files['image'].content_type.split('/')[-1].upper())
|
||||
|
||||
file_name = str(self.files['image'])
|
||||
img = InMemoryUploadedFile(thumb_io, "image", file_name, self.files['image'].content_type, thumb_io.len, None)
|
||||
thumb_io.seek(0, os.SEEK_END)
|
||||
img = InMemoryUploadedFile(thumb_io, "image", file_name, self.files['image'].content_type, thumb_io.tell(), None)
|
||||
|
||||
unique_file_name = self.get_unique_file_name(file_name)
|
||||
full_path = os.path.join(settings.MEDIA_ROOT, MARKDOWNX_MEDIA_PATH, unique_file_name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue