From b0b70d2f0fcd049328a3ba016079951af77959e1 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 1 Jan 2023 13:30:33 +0200 Subject: [PATCH] better 200w behavior --- files/assets/js/gif_modal.js | 2 +- files/helpers/sanitize.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/files/assets/js/gif_modal.js b/files/assets/js/gif_modal.js index 844c18c5c..c12e5ff54 100644 --- a/files/assets/js/gif_modal.js +++ b/files/assets/js/gif_modal.js @@ -142,7 +142,7 @@ async function searchGifs(searchTerm) { } else { for (let i = 0; i < 48; i++) { - gifURL[i] = "https://media.giphy.com/media/" + data[i].id + "/200w.webp"; + gifURL[i] = "https://media.giphy.com/media/" + data[i].id + "/giphy.webp"; const insert = `` container.insertAdjacentHTML('beforeend', insert); noGIFs.innerHTML = null; diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index d8a2907be..92ff4ddaf 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -313,6 +313,8 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys tag = tag.replace_with(a) a.append(tag) + tag["data-src"] = tag["data-src"].replace('/giphy.webp', '/200w.webp') + for tag in soup.find_all("a"): if not tag.contents or not str(tag.contents[0]).strip(): tag.extract() @@ -476,8 +478,7 @@ def normalize_url(url): .replace("https://nitter.net/", "https://twitter.com/") \ .replace("https://nitter.42l.fr/", "https://twitter.com/") \ .replace("https://nitter.lacontrevoie.fr/", "https://twitter.com/") \ - .replace("/giphy.gif", "/200w.webp") \ - .replace("/giphy.webp", "/200w.webp") \ + .replace("/giphy.gif", "/giphy.webp") url = imgur_regex.sub(r'\1_d.webp?maxwidth=9999&fidelity=grand', url) url = giphy_regex.sub(r'\1.webp', url)