-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3524 from huridocs/3494-media-field-revamp
3494 media field revamp
- Loading branch information
Showing
22 changed files
with
890 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { AttachmentSchema } from 'shared/types/commonTypes'; | ||
import MarkdownMedia from 'app/Markdown/components/MarkdownMedia'; | ||
import ReactPlayer from 'react-player'; | ||
|
||
export const RenderAttachment = ({ attachment }: { attachment: AttachmentSchema }) => { | ||
const { mimetype = '' } = attachment; | ||
|
||
if (mimetype.includes('image')) { | ||
return attachment.url ? ( | ||
<img src={attachment.url} alt={attachment.originalname} /> | ||
) : ( | ||
<img src={`/api/files/${attachment.filename}`} alt={attachment.originalname} /> | ||
); | ||
} | ||
|
||
const isVideoAudio = mimetype.includes('video') || mimetype.includes('audio'); | ||
|
||
const isFromSupportedSite = attachment.url && ReactPlayer.canPlay(attachment.url); | ||
|
||
if (isVideoAudio || isFromSupportedSite) { | ||
return attachment.url ? ( | ||
<MarkdownMedia config={`(${attachment.url})`} /> | ||
) : ( | ||
<MarkdownMedia config={`(/api/files/${attachment.filename})`} /> | ||
); | ||
} | ||
|
||
return null; | ||
}; |
Oops, something went wrong.