mirror of
https://github.com/System-End/Vencord.git
synced 2026-04-19 19:45:09 +00:00
FixImagesQuality: fix always making GIF embeds in chat animate
This commit is contained in:
parent
d4d3514dcc
commit
658ff5b216
1 changed files with 11 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue