summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/9788.bugfix1
-rw-r--r--synapse/config/repository.py1
-rw-r--r--synapse/rest/media/v1/media_repository.py3
3 files changed, 5 insertions, 0 deletions
diff --git a/changelog.d/9788.bugfix b/changelog.d/9788.bugfix
new file mode 100644
index 0000000000..edb58fbd5b
--- /dev/null
+++ b/changelog.d/9788.bugfix
@@ -0,0 +1 @@
+Fix thumbnail generation for some sites with non-standard content types. Contributed by @rkfg.
diff --git a/synapse/config/repository.py b/synapse/config/repository.py
index 146bc55d6f..c78a83abe1 100644
--- a/synapse/config/repository.py
+++ b/synapse/config/repository.py
@@ -70,6 +70,7 @@ def parse_thumbnail_requirements(thumbnail_sizes):
         jpeg_thumbnail = ThumbnailRequirement(width, height, method, "image/jpeg")
         png_thumbnail = ThumbnailRequirement(width, height, method, "image/png")
         requirements.setdefault("image/jpeg", []).append(jpeg_thumbnail)
+        requirements.setdefault("image/jpg", []).append(jpeg_thumbnail)
         requirements.setdefault("image/webp", []).append(jpeg_thumbnail)
         requirements.setdefault("image/gif", []).append(png_thumbnail)
         requirements.setdefault("image/png", []).append(png_thumbnail)
diff --git a/synapse/rest/media/v1/media_repository.py b/synapse/rest/media/v1/media_repository.py
index 87e3645ddc..e8a875b900 100644
--- a/synapse/rest/media/v1/media_repository.py
+++ b/synapse/rest/media/v1/media_repository.py
@@ -467,6 +467,9 @@ class MediaRepository:
         return media_info
 
     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, ())
 
     def _generate_thumbnail(