summary refs log tree commit diff
path: root/synapse/media
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-12-19 16:37:08 +0000
committerErik Johnston <erik@matrix.org>2014-12-19 16:37:08 +0000
commitd61109f5781fecfdc8b3ea1f1ae74a72f8a2a913 (patch)
treedff914dc74740d36be1da73be66a8b06c6c4feea /synapse/media
parentMerge branch 'release-v0.6.0' of github.com:matrix-org/synapse into erikj-perf (diff)
parentSet a state_key for the topic and room name, otherwise they won't be treated ... (diff)
downloadsynapse-d61109f5781fecfdc8b3ea1f1ae74a72f8a2a913.tar.xz
Merge branch 'hotfixes-v0.6.0' of github.com:matrix-org/synapse into erikj-perf
Diffstat (limited to 'synapse/media')
-rw-r--r--synapse/media/v1/thumbnail_resource.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/synapse/media/v1/thumbnail_resource.py b/synapse/media/v1/thumbnail_resource.py
index e19620d456..5ddcf54b9f 100644
--- a/synapse/media/v1/thumbnail_resource.py
+++ b/synapse/media/v1/thumbnail_resource.py
@@ -165,18 +165,27 @@ class ThumbnailResource(BaseMediaResource):
                         aspect_quality, size_quality, type_quality,
                         length_quality, info
                     ))
-            return min(info_list)[-1]
+            if info_list:
+                return min(info_list)[-1]
         else:
             info_list = []
+            info_list2 = []
             for info in thumbnail_infos:
                 t_w = info["thumbnail_width"]
                 t_h = info["thumbnail_height"]
                 t_method = info["thumbnail_method"]
+                size_quality = abs((d_w - t_w) * (d_h - t_h))
+                type_quality = desired_type != info["thumbnail_type"]
+                length_quality = info["thumbnail_length"]
                 if t_method == "scale" and (t_w >= d_w or t_h >= d_h):
-                    size_quality = abs((d_w - t_w) * (d_h - t_h))
-                    type_quality = desired_type != info["thumbnail_type"]
-                    length_quality = info["thumbnail_length"]
                     info_list.append((
                         size_quality, type_quality, length_quality, info
                     ))
-            return min(info_list)[-1]
+                elif t_method == "scale":
+                    info_list2.append((
+                        size_quality, type_quality, length_quality, info
+                    ))
+            if info_list:
+                return min(info_list)[-1]
+            else:
+                return min(info_list2)[-1]