summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-08-12 10:55:27 +0100
committerMark Haines <mark.haines@matrix.org>2015-08-12 10:55:27 +0100
commitfdb724cb7040a7746b2a6c6d8aabbf3654daf8dd (patch)
tree48c8c2acb04ca642afdf4783e0ae51fc6b5266ca /synapse/rest
parentMake a config option for whether to generate new thumbnail sizes dynamically (diff)
downloadsynapse-fdb724cb7040a7746b2a6c6d8aabbf3654daf8dd.tar.xz
Add config option for setting the list of thumbnail sizes to precalculate
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/media/v1/base_resource.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/synapse/rest/media/v1/base_resource.py b/synapse/rest/media/v1/base_resource.py
index e39729489e..271cbca2d6 100644
--- a/synapse/rest/media/v1/base_resource.py
+++ b/synapse/rest/media/v1/base_resource.py
@@ -70,6 +70,7 @@ class BaseMediaResource(Resource):
         self.version_string = hs.version_string
         self.downloads = {}
         self.dynamic_thumbnails = hs.config.dynamic_thumbnails
+        self.thumbnail_requirements = hs.config.thumbnail_requirements
 
     def _respond_404(self, request):
         respond_with_json(
@@ -209,22 +210,7 @@ class BaseMediaResource(Resource):
             self._respond_404(request)
 
     def _get_thumbnail_requirements(self, media_type):
-        if media_type == "image/jpeg":
-            return (
-                (32, 32, "crop", "image/jpeg"),
-                (96, 96, "crop", "image/jpeg"),
-                (320, 240, "scale", "image/jpeg"),
-                (640, 480, "scale", "image/jpeg"),
-            )
-        elif (media_type == "image/png") or (media_type == "image/gif"):
-            return (
-                (32, 32, "crop", "image/png"),
-                (96, 96, "crop", "image/png"),
-                (320, 240, "scale", "image/png"),
-                (640, 480, "scale", "image/png"),
-            )
-        else:
-            return ()
+        return self.thumbnail_requirements.get(media_type, ())
 
     def _generate_thumbnail(self, input_path, t_path, t_width, t_height,
                             t_method, t_type):