feat: use imgproxy to generate video posters
This commit is contained in:
parent
2ce5bd153b
commit
28fa0b4bc8
@ -1,4 +1,5 @@
|
|||||||
import { ProxyImg } from "Element/ProxyImg";
|
import { ProxyImg } from "Element/ProxyImg";
|
||||||
|
import useImgProxy from "Hooks/useImgProxy";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
interface MediaElementProps {
|
interface MediaElementProps {
|
||||||
@ -11,12 +12,14 @@ interface MediaElementProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function MediaElement(props: MediaElementProps) {
|
export function MediaElement(props: MediaElementProps) {
|
||||||
|
const { proxy } = useImgProxy();
|
||||||
|
|
||||||
if (props.mime.startsWith("image/")) {
|
if (props.mime.startsWith("image/")) {
|
||||||
return <ProxyImg key={props.url} src={props.url} onClick={props.onMediaClick} />;
|
return <ProxyImg key={props.url} src={props.url} onClick={props.onMediaClick} />;
|
||||||
} else if (props.mime.startsWith("audio/")) {
|
} else if (props.mime.startsWith("audio/")) {
|
||||||
return <audio key={props.url} src={props.url} controls />;
|
return <audio key={props.url} src={props.url} controls />;
|
||||||
} else if (props.mime.startsWith("video/")) {
|
} else if (props.mime.startsWith("video/")) {
|
||||||
return <video key={props.url} src={props.url} controls />;
|
return <video key={props.url} src={props.url} controls poster={proxy(props.url)} />;
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
|
Loading…
Reference in New Issue
Block a user