Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
pass back SVGs as their own thumbnails
Browse files Browse the repository at this point in the history
  • Loading branch information
ara4n committed Apr 2, 2016
1 parent 5037ee0 commit 2c838f6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions synapse/rest/media/v1/thumbnail_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def _respond_local_thumbnail(self, request, media_id, width, height,
self._respond_404(request)
return

if media_info["media_type"] == "image/svg+xml":
file_path = self.filepaths.local_media_filepath(media_id)
yield self._respond_with_file(request, media_info["media_type"], file_path)
return

thumbnail_infos = yield self.store.get_local_media_thumbnails(media_id)

if thumbnail_infos:
Expand Down Expand Up @@ -103,6 +108,11 @@ def _select_or_generate_local_thumbnail(self, request, media_id, desired_width,
self._respond_404(request)
return

if media_info["media_type"] == "image/svg+xml":
file_path = self.filepaths.local_media_filepath(media_id)
yield self._respond_with_file(request, media_info["media_type"], file_path)
return

thumbnail_infos = yield self.store.get_local_media_thumbnails(media_id)
for info in thumbnail_infos:
t_w = info["thumbnail_width"] == desired_width
Expand Down Expand Up @@ -138,6 +148,11 @@ def _select_or_generate_remote_thumbnail(self, request, server_name, media_id,
desired_method, desired_type):
media_info = yield self._get_remote_media(server_name, media_id)

if media_info["media_type"] == "image/svg+xml":
file_path = self.filepaths.remote_media_filepath(server_name, media_id)
yield self._respond_with_file(request, media_info["media_type"], file_path)
return

thumbnail_infos = yield self.store.get_remote_media_thumbnails(
server_name, media_id,
)
Expand Down Expand Up @@ -181,6 +196,11 @@ def _respond_remote_thumbnail(self, request, server_name, media_id, width,
# We should proxy the thumbnail from the remote server instead.
media_info = yield self._get_remote_media(server_name, media_id)

if media_info["media_type"] == "image/svg+xml":
file_path = self.filepaths.remote_media_filepath(server_name, media_id)
yield self._respond_with_file(request, media_info["media_type"], file_path)
return

thumbnail_infos = yield self.store.get_remote_media_thumbnails(
server_name, media_id,
)
Expand Down

0 comments on commit 2c838f6

Please sign in to comment.