This commit is contained in:
Kakabay 2023-03-23 18:07:14 +05:00
parent 77147a0fe7
commit 5e45d00d68
1 changed files with 14 additions and 5 deletions

View File

@ -1,7 +1,8 @@
// Modules
import placeholder from "../../assets/images/placeholder.webp";
import { LazyLoadImage } from "react-lazy-load-image-component";
import ReactPlayer from "react-player";
import { useState, useEffect } from 'react';
import placeholder from '../../assets/images/placeholder.webp';
import { LazyLoadImage } from 'react-lazy-load-image-component';
import ReactPlayer from 'react-player';
interface IProps {
img: string;
@ -9,10 +10,18 @@ interface IProps {
}
const NewsArticleImg = ({ img, video }: IProps) => {
console.log(video);
const [videoParse, setVideoParse] = useState<string>('');
useEffect(() => {
const videoModify = video?.replace(' ', '%20');
setVideoParse(videoModify as string);
}, []);
return (
<div className={"news-article-image"}>
<div className={'news-article-image'}>
{video && video.length > 53 ? (
<ReactPlayer url={video} controls width="100%" height="100%" />
<ReactPlayer url={videoParse} controls width="100%" height="100%" />
) : (
<LazyLoadImage
src={img}