mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 00:33:46 +01:00
More robust handling of the Content-Type header for thumbnail generation (#9788)
Signed-off-by: Sergey Shpikin <rkfg@rkfg.me>
This commit is contained in:
parent
4b965c862d
commit
c9a2b5d402
3 changed files with 5 additions and 0 deletions
1
changelog.d/9788.bugfix
Normal file
1
changelog.d/9788.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix thumbnail generation for some sites with non-standard content types. Contributed by @rkfg.
|
|
@ -70,6 +70,7 @@ def parse_thumbnail_requirements(thumbnail_sizes):
|
||||||
jpeg_thumbnail = ThumbnailRequirement(width, height, method, "image/jpeg")
|
jpeg_thumbnail = ThumbnailRequirement(width, height, method, "image/jpeg")
|
||||||
png_thumbnail = ThumbnailRequirement(width, height, method, "image/png")
|
png_thumbnail = ThumbnailRequirement(width, height, method, "image/png")
|
||||||
requirements.setdefault("image/jpeg", []).append(jpeg_thumbnail)
|
requirements.setdefault("image/jpeg", []).append(jpeg_thumbnail)
|
||||||
|
requirements.setdefault("image/jpg", []).append(jpeg_thumbnail)
|
||||||
requirements.setdefault("image/webp", []).append(jpeg_thumbnail)
|
requirements.setdefault("image/webp", []).append(jpeg_thumbnail)
|
||||||
requirements.setdefault("image/gif", []).append(png_thumbnail)
|
requirements.setdefault("image/gif", []).append(png_thumbnail)
|
||||||
requirements.setdefault("image/png", []).append(png_thumbnail)
|
requirements.setdefault("image/png", []).append(png_thumbnail)
|
||||||
|
|
|
@ -467,6 +467,9 @@ class MediaRepository:
|
||||||
return media_info
|
return media_info
|
||||||
|
|
||||||
def _get_thumbnail_requirements(self, media_type):
|
def _get_thumbnail_requirements(self, media_type):
|
||||||
|
scpos = media_type.find(";")
|
||||||
|
if scpos > 0:
|
||||||
|
media_type = media_type[:scpos]
|
||||||
return self.thumbnail_requirements.get(media_type, ())
|
return self.thumbnail_requirements.get(media_type, ())
|
||||||
|
|
||||||
def _generate_thumbnail(
|
def _generate_thumbnail(
|
||||||
|
|
Loading…
Reference in a new issue