From 658ff5b216015dddd2bd4f6055af93c4503e0831 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 9 Jan 2026 21:00:01 +0100 Subject: [PATCH] FixImagesQuality: fix always making GIF embeds in chat animate --- src/plugins/fixImagesQuality/index.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/fixImagesQuality/index.tsx b/src/plugins/fixImagesQuality/index.tsx index d446e421..527c8f41 100644 --- a/src/plugins/fixImagesQuality/index.tsx +++ b/src/plugins/fixImagesQuality/index.tsx @@ -60,11 +60,12 @@ export default definePlugin({ ); }, - getSrc(props: { src: string; mediaLayoutType: string; width: number; height: number; contentType: string; mosaicStyleAlt?: boolean; }, freeze?: boolean) { + getSrc(props: { src: string; width: number; height: number; contentType: string; mosaicStyleAlt?: boolean; trigger?: string; }, freeze?: boolean) { if (!props?.src) return; try { - const { contentType, height, mediaLayoutType, src, width, mosaicStyleAlt } = props; + const { contentType, height, src, width, mosaicStyleAlt, trigger } = props; + // Embed images do not have a content type set. // It's difficult to differentiate between images and videos. but mosaicStyleAlt seems exclusive to images const isImage = contentType?.startsWith("image/") ?? (typeof mosaicStyleAlt === "boolean"); @@ -73,9 +74,15 @@ export default definePlugin({ const url = new URL(src); if (!url.pathname.startsWith("/attachments/")) return; - url.searchParams.set("animated", String(!freeze)); + if (freeze) { + url.searchParams.set("animated", "false"); - if (!settings.store.originalImagesInChat && mediaLayoutType === "MOSAIC") { + if (url.pathname.endsWith(".gif")) + url.searchParams.set("format", "webp"); + } + + const isModal = !!trigger; + if (!settings.store.originalImagesInChat && !isModal) { // make sure the image is not too large const pixels = width * height; const limit = 2000 * 1200;