From 835c5f810d0a4c22573cd179b53cfcd0a7a5d758 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 12 Mar 2023 15:13:28 +0200 Subject: [PATCH] use .img class --- files/assets/css/chat.css | 2 +- files/assets/css/main.css | 2 +- files/assets/js/bottom.js | 2 +- files/helpers/sanitize.py | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/files/assets/css/chat.css b/files/assets/css/chat.css index 68dd1bd3c..bb517e990 100644 --- a/files/assets/css/chat.css +++ b/files/assets/css/chat.css @@ -145,7 +145,7 @@ lite-youtube { margin: 14px 0 0 0!important; } -img[alt^="![]("] { +img[alt^="![]("], .img { height: 150px; width: 90%; -o-object-fit: contain; diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 9e131c743..c2ba54064 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -7137,7 +7137,7 @@ body { line-height: 2.3; } -.dm_img[alt^="![]("] { +.dm_img { width: 200px; max-height: 100vh !important; } diff --git a/files/assets/js/bottom.js b/files/assets/js/bottom.js index ff840161f..c3a0cdee5 100644 --- a/files/assets/js/bottom.js +++ b/files/assets/js/bottom.js @@ -155,7 +155,7 @@ bs_trigger(document); document.addEventListener("click", function(e){ const element = e.target - if (element instanceof HTMLImageElement && (element.alt.startsWith('![](')) || element.classList.contains('in-comment-image')) { + if (element instanceof HTMLImageElement && (element.alt.startsWith('![](')) || element.classList.contains('in-comment-image') || element.classList.contains('img')) { expandImage() } else if (element.classList.contains('showmore')) { diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index c9f27deae..6948242a2 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -76,6 +76,7 @@ def allowed_attributes(tag, name, value): if name == 'data-bs-toggle' and value == 'tooltip': return True if name in {'g','b','glow'} and not value: return True if name in {'alt','title'}: return True + if name == 'class' and value == 'img': return True if tag == 'lite-youtube': if name == 'params' and value.startswith('autoplay=1&modestbranding=1'): return True @@ -415,6 +416,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys tag["data-src"] = tag["src"] tag["src"] = "/i/l.webp" tag['alt'] = tag["data-src"] + tag['class'] = "img" if tag.parent.name != 'a': a = soup.new_tag("a", href=tag["data-src"])