gif support for chat

This commit is contained in:
Thomas Zarebczan 2022-03-23 10:16:10 -04:00
parent 8fd64b2b41
commit c362efe630
No known key found for this signature in database
GPG key ID: 767B41E1BB7346F2

View file

@ -3,7 +3,7 @@ import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS, MISSING_THUMB_DEFAULT } from 'conf
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 { getThumbnailCdnUrl, getImageProxyUrl } 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';
@ -198,9 +198,13 @@ 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) => {
// getImageProxyUrl() can also be used if we just want to proxy without compression. const isGif = imgProps.src && imgProps.src.endsWith('gif');
const imageCdnUrl = const imageCdnUrl =
getThumbnailCdnUrl({ thumbnail: imgProps.src, width: 0, height: 0, quality: 85 }) || MISSING_THUMB_DEFAULT; (isGif
? getImageProxyUrl(imgProps.src)
: getThumbnailCdnUrl({ thumbnail: imgProps.src, width: 0, height: 0, quality: 85 })) ||
MISSING_THUMB_DEFAULT;
if ((isStakeEnoughForPreview(stakedLevel) || hasMembership) && !isEmote(imgProps.title, imgProps.src)) { if ((isStakeEnoughForPreview(stakedLevel) || hasMembership) && !isEmote(imgProps.title, imgProps.src)) {
return <ZoomableImage {...imgProps} src={imageCdnUrl} />; return <ZoomableImage {...imgProps} src={imageCdnUrl} />;
} else { } else {