🦉 allow images

This commit is contained in:
2026-04-15 20:49:40 +02:00
parent 8c892f14f8
commit 1173c17452
2 changed files with 10 additions and 28 deletions

View File

@@ -474,14 +474,10 @@ export const getReactCustomHtmlParser = (
}
if (name === 'img') {
const htmlSrc = mxcUrlToHttp(mx, props.src, params.useAuthentication);
if (htmlSrc && props.src.startsWith('mxc://') === false) {
return (
<a href={htmlSrc} target="_blank" rel="noreferrer noopener">
{props.alt || props.title || htmlSrc}
</a>
);
}
const isMxc = typeof props.src === 'string' && props.src.startsWith('mxc://');
const htmlSrc = isMxc
? mxcUrlToHttp(mx, props.src, params.useAuthentication)
: props.src;
if (htmlSrc && 'data-mx-emoticon' in props) {
return (
<span className={css.EmoticonBase}>

View File

@@ -105,26 +105,12 @@ const transformATag: Transformer = (tagName, attribs) => ({
},
});
const transformImgTag: Transformer = (tagName, attribs) => {
const { src } = attribs;
if (typeof src === 'string' && src.startsWith('mxc://') === false) {
return {
tagName: 'a',
attribs: {
href: src,
rel: 'noreferrer noopener',
target: '_blank',
},
text: attribs.alt || src,
};
}
return {
tagName,
attribs: {
...attribs,
},
};
};
const transformImgTag: Transformer = (tagName, attribs) => ({
tagName,
attribs: {
...attribs,
},
});
export const sanitizeCustomHtml = (customHtml: string): string =>
sanitizeHtml(customHtml, {