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";
|
||||
|
||||
// Re-use dom parser across instances of TidalEmbed
|
||||
@ -34,6 +34,7 @@ async function oembedLookup (link: string) {
|
||||
const TidalEmbed = ({ link }: { link: string }) => {
|
||||
const [source, setSource] = useState<string>();
|
||||
const [height, setHeight] = useState<number>();
|
||||
const extraStyles = link.includes('video') ? { aspectRatio: "16 / 9" } : { height };
|
||||
|
||||
useEffect(() => {
|
||||
oembedLookup(link).then(data => {
|
||||
@ -43,7 +44,7 @@ const TidalEmbed = ({ link }: { link: string }) => {
|
||||
}, [link]);
|
||||
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user