Embedded images: serve via CDN for IP protection. (#1009)

## Ticket
536 "Embedding images without proxy is probably not in compliance with data protection regulations in Germany/Europe (GDPR)"
This commit is contained in:
infinite-persistence 2022-03-02 08:23:34 -08:00 committed by GitHub
parent 27f70d5f90
commit 2eae20f0bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,9 @@
// @flow // @flow
import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS, SIMPLE_SITE } from 'config'; import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS, MISSING_THUMB_DEFAULT } from 'config';
import { formattedEmote, inlineEmote } from 'util/remark-emote'; import { formattedEmote, inlineEmote } from 'util/remark-emote';
import { formattedLinks, inlineLinks } from 'util/remark-lbry'; import { formattedLinks, inlineLinks } from 'util/remark-lbry';
import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp'; import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp';
import { getThumbnailCdnUrl } from 'util/thumbnail';
import * as ICONS from 'constants/icons'; import * as ICONS from 'constants/icons';
import * as React from 'react'; import * as React from 'react';
import Button from 'component/button'; import Button from 'component/button';
@ -194,17 +195,22 @@ export default React.memo<MarkdownProps>(function MarkdownPreview(props: Markdow
), ),
// Workaraund of remarkOptions.Fragment // Workaraund of remarkOptions.Fragment
div: React.Fragment, div: React.Fragment,
img: (imgProps) => img: (imgProps) => {
isStakeEnoughForPreview(stakedLevel) && !isEmote(imgProps.title, imgProps.src) ? ( const imageCdnUrl =
<ZoomableImage {...imgProps} /> getThumbnailCdnUrl({ thumbnail: imgProps.src, width: 0, height: 0, quality: 85 }) || MISSING_THUMB_DEFAULT;
) : ( if (isStakeEnoughForPreview(stakedLevel) && !isEmote(imgProps.title, imgProps.src)) {
<SimpleImageLink return <ZoomableImage {...imgProps} src={imageCdnUrl} />;
src={imgProps.src} } else {
alt={imgProps.alt} return (
title={imgProps.title} <SimpleImageLink
helpText={SIMPLE_SITE ? __("This channel isn't staking enough Credits for inline image previews.") : ''} src={imageCdnUrl}
/> alt={imgProps.alt}
), title={imgProps.title}
helpText={__("This channel isn't staking enough Credits for inline image previews.")}
/>
);
}
},
}, },
}; };