forked from Kieran/snort
Make sure videos are 16:9
This commit is contained in:
parent
43c074fa4c
commit
f8fd626673
@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { CSSProperties, useEffect, useState } from "react";
|
||||||
import { TidalRegex } from "Const";
|
import { TidalRegex } from "Const";
|
||||||
|
|
||||||
// Re-use dom parser across instances of TidalEmbed
|
// Re-use dom parser across instances of TidalEmbed
|
||||||
@ -34,6 +34,7 @@ async function oembedLookup (link: string) {
|
|||||||
const TidalEmbed = ({ link }: { link: string }) => {
|
const TidalEmbed = ({ link }: { link: string }) => {
|
||||||
const [source, setSource] = useState<string>();
|
const [source, setSource] = useState<string>();
|
||||||
const [height, setHeight] = useState<number>();
|
const [height, setHeight] = useState<number>();
|
||||||
|
const extraStyles = link.includes('video') ? { aspectRatio: "16 / 9" } : { height };
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
oembedLookup(link).then(data => {
|
oembedLookup(link).then(data => {
|
||||||
@ -43,7 +44,7 @@ const TidalEmbed = ({ link }: { link: string }) => {
|
|||||||
}, [link]);
|
}, [link]);
|
||||||
|
|
||||||
if (!source) return <a href={link} target="_blank" rel="noreferrer" onClick={(e) => e.stopPropagation()} className="ext">{link}</a>;
|
if (!source) return <a href={link} target="_blank" rel="noreferrer" onClick={(e) => e.stopPropagation()} className="ext">{link}</a>;
|
||||||
return <iframe src={source} height={height} width="100%" title="TIDAL Embed" frameBorder={0} />;
|
return <iframe src={source} style={extraStyles} width="100%" title="TIDAL Embed" frameBorder={0} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TidalEmbed;
|
export default TidalEmbed;
|
||||||
|
Loading…
Reference in New Issue
Block a user