FixImagesQuality: fix not applying to embed images

This commit is contained in:
Vendicated 2026-01-05 17:31:44 +01:00
parent 5b7b033df7
commit 5d56820a5d
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -60,12 +60,15 @@ export default definePlugin({
);
},
getSrc(props: { src: string; mediaLayoutType: string; width: number; height: number; contentType: string; }, freeze?: boolean) {
getSrc(props: { src: string; mediaLayoutType: string; width: number; height: number; contentType: string; mosaicStyleAlt?: boolean; }, freeze?: boolean) {
if (!props?.src) return;
try {
const { contentType, height, mediaLayoutType, src, width } = props;
if (!contentType?.startsWith("image/") || src.startsWith("data:")) return;
const { contentType, height, mediaLayoutType, src, width, mosaicStyleAlt } = 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");
if (!isImage || src.startsWith("data:")) return;
const url = new URL(src);
if (!url.pathname.startsWith("/attachments/")) return;