Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e1e77b2

Browse files
authored
Merge pull request #5361 from matrix-org/jryans/hide-inline-images
Hide inline images when preference disabled
2 parents 557d9ad + 5f840da commit e1e77b2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/HtmlUtils.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import EMOJIBASE_REGEX from 'emojibase-regex';
2929
import url from 'url';
3030

3131
import {MatrixClientPeg} from './MatrixClientPeg';
32+
import SettingsStore from './settings/SettingsStore';
3233
import {tryTransformPermalinkToLocalHref} from "./utils/permalinks/Permalinks";
3334
import {SHORTCODE_TO_EMOJI, getEmojiFromUnicode} from "./emoji";
3435
import ReplyThread from "./components/views/elements/ReplyThread";
@@ -171,7 +172,10 @@ const transformTags: IExtendedSanitizeOptions["transformTags"] = { // custom to
171172
// Strip out imgs that aren't `mxc` here instead of using allowedSchemesByTag
172173
// because transformTags is used _before_ we filter by allowedSchemesByTag and
173174
// we don't want to allow images with `https?` `src`s.
174-
if (!attribs.src || !attribs.src.startsWith('mxc://')) {
175+
// We also drop inline images (as if they were not present at all) when the "show
176+
// images" preference is disabled. Future work might expose some UI to reveal them
177+
// like standalone image events have.
178+
if (!attribs.src || !attribs.src.startsWith('mxc://') || !SettingsStore.getValue("showImages")) {
175179
return { tagName, attribs: {}};
176180
}
177181
attribs.src = MatrixClientPeg.get().mxcUrlToHttp(

0 commit comments

Comments
 (0)