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