|
4 | 4 | from collections import namedtuple
|
5 | 5 |
|
6 | 6 | from django import forms
|
7 |
| -from django.core.files.storage import default_storage |
| 7 | +from django.core.files.storage import get_storage_class |
8 | 8 | from django.core.files.uploadedfile import InMemoryUploadedFile
|
9 | 9 |
|
10 | 10 | from .utils import scale_and_crop, xml_has_javascript
|
11 | 11 | from .exceptions import MarkdownxImageUploadError
|
12 | 12 |
|
13 | 13 | from .settings import (
|
14 | 14 | MARKDOWNX_IMAGE_MAX_SIZE,
|
| 15 | + MARKDOWNX_IMAGE_STORAGE, |
15 | 16 | MARKDOWNX_MEDIA_PATH,
|
16 | 17 | MARKDOWNX_UPLOAD_CONTENT_TYPES,
|
17 | 18 | MARKDOWNX_UPLOAD_MAX_SIZE,
|
18 | 19 | MARKDOWNX_SVG_JAVASCRIPT_PROTECTION
|
19 | 20 | )
|
20 | 21 |
|
21 | 22 |
|
| 23 | +image_storage = get_storage_class(MARKDOWNX_IMAGE_STORAGE)() |
| 24 | + |
| 25 | + |
22 | 26 | class ImageForm(forms.Form):
|
23 | 27 | """
|
24 | 28 | Used for the handling of images uploaded using the editor through :guilabel:`AJAX`.
|
@@ -104,8 +108,8 @@ def _save(self, image, file_name, commit):
|
104 | 108 | full_path = path.join(MARKDOWNX_MEDIA_PATH, unique_file_name)
|
105 | 109 |
|
106 | 110 | if commit:
|
107 |
| - default_storage.save(full_path, image) |
108 |
| - return default_storage.url(full_path) |
| 111 | + image_storage.save(full_path, image) |
| 112 | + return image_storage.url(full_path) |
109 | 113 |
|
110 | 114 | # If `commit is False`, return the path and in-memory image.
|
111 | 115 | image_data = namedtuple('image_data', ['path', 'image'])
|
|
0 commit comments