Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

thumbnail: Extract needs_transcoded_format helper.

Aman Agrawal1dca4291f089
diff --git a/zerver/lib/thumbnail.py b/zerver/lib/thumbnail.py
index db3b2308878..5bc6afab7ef 100644
--- a/zerver/lib/thumbnail.py
+++ b/zerver/lib/thumbnail.py
@@ -294,6 +294,13 @@ def resize_emoji(
return (animated.write_to_buffer(write_file_ext), first_still)
+def needs_transcoded_format(image_attachment: ImageAttachment) -> bool:
+ return not (
+ image_attachment.content_type is None
+ or bare_content_type(image_attachment.content_type) in INLINE_MIME_TYPES
+ )
+
+
def missing_thumbnails(
image_attachment: ImageAttachment,
) -> list[ThumbnailFormat]:
@@ -524,10 +531,7 @@ def get_transcoded_format(
# not in INLINE_MIME_TYPES get an extra large-resolution thumbnail
# added to their list of formats, this is thus either None or a
# high-resolution thumbnail.
- if (
- image_attachment.content_type is None
- or bare_content_type(image_attachment.content_type) in INLINE_MIME_TYPES
- ):
+ if not needs_transcoded_format(image_attachment):
return None
thumbs_by_size = sorted(