Skip to content

Commit 35c6a0d

Browse files
option for custom thumbnail (#47)
1 parent c213434 commit 35c6a0d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

β€Žpackage-lock.jsonβ€Ž

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žsrc/lib/index.tsxβ€Ž

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface LiteYouTube {
2727
wrapperClass?: string;
2828
onIframeAdded?: () => void
2929
muted?: boolean,
30+
thumbnail: string,
3031
}
3132

3233
export default function LiteYouTubeEmbed(props: LiteYouTube) {
@@ -41,9 +42,10 @@ export default function LiteYouTubeEmbed(props: LiteYouTube) {
4142
const announceWatch = props.announce || "Watch";
4243
const format = props.webp ? 'webp' : 'jpg';
4344
const vi = props.webp ? 'vi_webp' : 'vi'
44-
const posterUrl = !props.playlist ?
45-
`https://i.ytimg.com/${vi}/${videoId}/${posterImp}.${format}` :
46-
`https://i.ytimg.com/${vi}/${videoPlaylisCovertId}/${posterImp}.${format}`;
45+
const posterUrl = props.thumbnail || (!props.playlist
46+
? `https://i.ytimg.com/${vi}/${videoId}/${posterImp}.${format}`
47+
: `https://i.ytimg.com/${vi}/${videoPlaylisCovertId}/${posterImp}.${format}`);
48+
4749
let ytUrl = props.noCookie
4850
? "https://www.youtube-nocookie.com"
4951
: "https://www.youtube.com";

0 commit comments

Comments
Β (0)