feat(post): add support for static GIFs

This commit is contained in:
Tom (plebeius.eth)
2024-07-20 16:25:20 +02:00
parent b3f0b04e43
commit 7253e4d1a0
39 changed files with 134 additions and 41 deletions
+11 -1
View File
@@ -68,6 +68,8 @@ const Thumbnail = ({ commentMediaInfo, isFloatingEmbed, post, setShowThumbnail }
thumbnailComponent = iframeThumbnail ? <img src={iframeThumbnail} alt='' onClick={() => setShowThumbnail(false)} /> : null;
} else if (type === 'gif' && gifFrameUrl) {
thumbnailComponent = <img src={gifFrameUrl} alt='' onClick={() => setShowThumbnail(false)} />;
} else if (type === 'gif' && !gifFrameUrl) {
thumbnailComponent = <img src={url} alt='' onClick={() => setShowThumbnail(false)} />;
} else if (type === 'audio') {
thumbnailComponent = <audio src={url} controls />;
}
@@ -145,7 +147,15 @@ const Media = ({ commentMediaInfo, isReply, setShowThumbnail }: MediaProps) => {
const CommentMedia = ({ commentMediaInfo, isFloatingEmbed, post, showThumbnail, setShowThumbnail }: MediaProps) => {
const { t } = useTranslation();
const isMobile = useIsMobile();
const { type, url } = commentMediaInfo || {};
const { url } = commentMediaInfo || {};
let type = commentMediaInfo?.type;
const gifFrameUrl = useFetchGifFirstFrame(url);
if (type === 'gif' && gifFrameUrl) {
type = 'animated gif';
} else if (type === 'gif' && !gifFrameUrl) {
type = 'static gif';
}
return (
<span className={styles.content}>