Skip to content

Commit 62551a1

Browse files
GaretJaxmichjnich
andauthored
Fix thumbnail generation for SVG images when used as a Divio addon (#1312)
* Fix thumbnail generation for SVG images when used as a Divio addon Remove hardcoded settings from alrdryn_config.py and use the defaults provided by easy-thumbnails. * Override easy-thumbnail default processor * Take default settings from easythumbnail conf * Isolate settings * Import easy inside class * Remove debug message Co-authored-by: Michael J. Nicholson <[email protected]>
1 parent b6c061b commit 62551a1

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
CHANGELOG
33
=========
44

5+
6+
Unreleased
7+
==========
8+
9+
* Fix thumbnail generation for SVG images when used as a Divio addon.
10+
11+
512
2.2.3 (2022-08-08)
613
==================
714
* Fix CSS styles (Modified SCSS had to be recompiled).

aldryn_config.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ def to_settings(self, data, settings):
88

99
from aldryn_addons.utils import boolean_ish, djsenv
1010
from aldryn_django import storage
11+
from easy_thumbnails.conf import Settings as EasySettings
1112

13+
EasyThumbnailSettings = EasySettings(isolated=True)
1214
env = partial(djsenv, settings=settings)
1315

1416
# django-filer
@@ -29,17 +31,16 @@ def to_settings(self, data, settings):
2931
# easy-thumbnails
3032
settings['THUMBNAIL_QUALITY'] = env('THUMBNAIL_QUALITY', 90)
3133
settings['THUMBNAIL_PRESERVE_EXTENSIONS'] = ['png', 'gif']
32-
settings['THUMBNAIL_PROCESSORS'] = (
33-
'easy_thumbnails.processors.colorspace',
34-
'easy_thumbnails.processors.autocrop',
35-
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
36-
'easy_thumbnails.processors.filters',
37-
)
38-
settings['THUMBNAIL_SOURCE_GENERATORS'] = (
39-
'easy_thumbnails.source_generators.pil_image',
40-
)
4134
settings['THUMBNAIL_CACHE_DIMENSIONS'] = True
4235

36+
# Swap scale and crop for django-filer version
37+
settings['THUMBNAIL_PROCESSORS'] = tuple([
38+
processor
39+
if processor != 'easy_thumbnails.processors.scale_and_crop'
40+
else 'filer.thumbnail_processors.scale_and_crop_with_subject_location'
41+
for processor in EasyThumbnailSettings.THUMBNAIL_PROCESSORS
42+
])
43+
4344
# easy_thumbnails uses django's default storage backend (local file
4445
# system storage) by default, even if the DEFAULT_FILE_STORAGE setting
4546
# points to something else.

0 commit comments

Comments
 (0)