From bf21311b2bc9e005b008d26afba3924e0bfc62ad Mon Sep 17 00:00:00 2001 From: glwntd Date: Tue, 17 Dec 2024 21:06:45 +0100 Subject: [PATCH] render images in preview --- pyglossary/ui/ui_web/server_ws_http.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pyglossary/ui/ui_web/server_ws_http.py b/pyglossary/ui/ui_web/server_ws_http.py index addffe08d..a95190716 100644 --- a/pyglossary/ui/ui_web/server_ws_http.py +++ b/pyglossary/ui/ui_web/server_ws_http.py @@ -49,7 +49,6 @@ - Website: https://legbehindneck.com """ import base64 - import errno import json import logging @@ -480,10 +479,16 @@ def browse_glossary(self, path): num_results += 1 else: response.append(f"📎
{entry.s_word}
") - if entry.isData() and entry.size() < MAX_IMAGE_SIZE and entry.s_word.lower().endswith(('.jpg', 'jpeg','.png')): + if ( + entry.isData() + and entry.size() < MAX_IMAGE_SIZE + and entry.s_word.lower().endswith((".jpg", "jpeg", ".png")) + ): extension = Path(entry.s_word).suffix[1:] response.append(f""" - {entry.s_word} + {entry.s_word} """) if num_results >= max_results: break