Skip to content

Commit 98f6eda

Browse files
authored
Merge pull request #4244 from GeotrekCE/fix_thumbnail_error_api_v2
🐛 [BUG] Fix ZeroDivisionError raised on generating thumbnails in APIv2 (refs #4231)
2 parents 35d39c8 + fe4fcc4 commit 98f6eda

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

docs/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CHANGELOG
1313

1414
- Fix empty linetring in reorder_topology cmd (fixes #4092)
1515
- Prevent Pillow Decompressed Data Too Large Error from interrupting Parsers
16+
- Fix ZeroDivisionError raised on generating thumbnails in APIv2 (#4231)
1617

1718

1819
2.108.0 (2024-07-12)

geotrek/api/v2/serializers.py

+2
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ def get_attachment_file(self, obj):
274274

275275
def get_thumbnail(self, obj):
276276
thumbnailer = get_thumbnailer(self.get_attachment_file(obj))
277+
if hasattr(obj, 'is_image') and not obj.is_image:
278+
return ""
277279
try:
278280
thumbnail = thumbnailer.get_thumbnail(aliases.get('apiv2'))
279281
except (IOError, InvalidImageFormatError, DecompressionBombError, NoSourceGenerator):

0 commit comments

Comments
 (0)