fix(pages): videos supported on embeded uploads

This commit is contained in:
diced 2022-06-20 14:33:10 -07:00
parent fb098c9147
commit af59e9abb8
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1

View file

@ -30,6 +30,7 @@ export default function EmbeddedImage({ image, user, pass }) {
};
const updateImage = async (url?: string) => {
const imageEl = document.getElementById('image_content') as HTMLImageElement;
const img = new Image();
@ -62,8 +63,19 @@ export default function EmbeddedImage({ image, user, pass }) {
<meta property='theme-color' content={user.embedColor} />
</>
)}
<meta property='og:image' content={dataURL('/r')} />
<meta property='twitter:card' content='summary_large_image' />
{image.mimetype.startsWith('image') && (
<>
<meta property='og:image' content={dataURL('/r')} />
<meta property='twitter:card' content='summary_large_image' />
</>
)}
{image.mimetype.startsWith('video') && (
<>
<meta property='og:video' content={dataURL('/r')} />
<meta property='og:video:url' content={dataURL('/r')} />
<meta property='og:video:type' content={image.mimetype} />
</>
)}
<title>{image.file}</title>
</Head>
<Modal
@ -88,7 +100,18 @@ export default function EmbeddedImage({ image, user, pass }) {
justifyContent: 'center',
}}
>
<img src={dataURL('/r')} alt={dataURL('/r')} id='image_content' />
{image.mimetype.startsWith('image') && (
<img src={dataURL('/r')} alt={dataURL('/r')} id='image_content' />
)}
{image.mimetype.startsWith('video') && (
<video
src={dataURL('/r')}
controls={true}
autoPlay={true}
id='image_content'
/>
)}
</Box>
</>
);
@ -168,7 +191,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
},
};
if (!image.mimetype.startsWith('image')) {
if (!image.mimetype.startsWith('image') && !image.mimetype.startsWith('video')) {
const { default: datasource } = await import('lib/datasource');
const data = datasource.get(image.file);