imagekit-developer / imagekit-react

React SDK for using ImageKit.io
https://imagekit.io
MIT License
102 stars 28 forks source link

Video support? #68

Closed VityaSchel closed 2 years ago

pip8786 commented 2 years ago

I contacted them and they said it hasn't been added yet. Here's a very simple version I wrote for myself using some of their libraries:

type IKVideoProps = {
    path: string;
    t: Transformation;
};

function IKVideo({ path, t }: IKVideoProps) {
    const ikClient = useMemo(() => {
        return new ImageKit({
            urlEndpoint: ImageKitEndpoint,
            transformationPosition: "query",
        });
    }, []);
    const videoURL = ikClient.url({
        path,
        transformation: [t],
    });
    return (
        <video controls width={t.width} height={t.height}>
            <source src={videoURL} type="video/mp4" />
        </video>
    );
}
imagekitio commented 2 years ago

Added in version 2.0.0 - https://github.com/imagekit-developer/imagekit-react#video-resizing