misc: disable ckeditor thumbnail generation for gif files (#29210)
This commit is contained in:
parent
1563f06479
commit
f347924d23
|
@ -22,7 +22,9 @@ from django.utils.html import conditional_escape
|
|||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import get_language
|
||||
|
||||
import ckeditor.views
|
||||
import ckeditor.widgets
|
||||
from ckeditor.image import pillow_backend
|
||||
|
||||
def ckeditor_render(self, name, value, attrs=None):
|
||||
if value is None:
|
||||
|
@ -51,3 +53,20 @@ def ckeditor_render(self, name, value, attrs=None):
|
|||
}))
|
||||
|
||||
ckeditor.widgets.CKEditorWidget.render = ckeditor_render
|
||||
|
||||
orig_should_create_thumbnail = pillow_backend.should_create_thumbnail
|
||||
|
||||
def should_create_thumbnail(file_path):
|
||||
if file_path.endswith('.gif'):
|
||||
# disable thumbnails for gif to workaround
|
||||
# https://github.com/python-pillow/Pillow/issues/2803
|
||||
return False
|
||||
return orig_should_create_thumbnail(file_path)
|
||||
|
||||
|
||||
def get_backend():
|
||||
backend = pillow_backend
|
||||
backend.should_create_thumbnail = should_create_thumbnail
|
||||
return backend
|
||||
|
||||
ckeditor.views.image_processing.get_backend = get_backend
|
||||
|
|
Loading…
Reference in New Issue