Skip to content

Commit aab8428

Browse files
harlan-zwserkodev
andauthored
feat(youtube): thumbnailSize prop with fallback support (#376)
Co-authored-by: SerKo <[email protected]>
1 parent ddc88a4 commit aab8428

File tree

6 files changed

+216
-288
lines changed

6 files changed

+216
-288
lines changed

.github/workflows/ci.yml

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ jobs:
1717
- uses: actions/checkout@v4
1818
- uses: pnpm/action-setup@v4
1919
name: Install pnpm
20-
with:
21-
version: 9.15.2
22-
run_install: false
2320
- name: Install Node.js
2421
uses: actions/setup-node@v4
2522
with:

.github/workflows/release.yml

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818
- uses: pnpm/action-setup@v4
19-
name: Install pnpm
20-
with:
21-
version: 9.15.2
22-
run_install: false
2319
- name: Install Node.js
2420
uses: actions/setup-node@v4
2521
with:

docs/content/scripts/content/youtube-player.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,23 @@ To modify this behavior, you can set the `host` prop to `https://www.youtube.com
105105
<ScriptYouTubePlayer video-id="d_IFKP1Ofq0" :player-options="{ host: 'https://www.youtube.com' }" />
106106
```
107107

108-
#### Eager Loading Placeholder
108+
### Placeholder
109109

110-
The YouTube Player placeholder image is lazy-loaded by default. You should change this behavior if your video is above the fold
110+
The YouTube Player placeholder image is 1280x720 webp that is lazy-loaded by default.
111+
112+
To modify the placeholder size you can set the `thumbnailSize` prop, if you'd prefer
113+
to use a `jpg` you can pass the `webp` prop as `false`.
114+
115+
```vue
116+
<ScriptYouTubePlayer video-id="d_IFKP1Ofq0" thumbnail-size="maxresdefault" />
117+
```
118+
119+
If you need fine control over the placeholder you can set `placeholderAttrs` prop or completely override it using
120+
the `#placeholder` slot.
121+
122+
#### Eager Loading
123+
124+
You should change this behavior if your video is above the fold
111125
or consider using the `#placeholder` slot to customize the placeholder image.
112126

113127
::code-group

playground/pages/third-parties/youtube/nuxt-scripts.vue

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ const videoid = ref('d_IFKP1Ofq0')
66
function changeVideo() {
77
videoid.value = 'N8siuNjyV7A'
88
}
9+
10+
function changeVideoFallback() {
11+
videoid.value = 'jNQXAC9IVRw'
12+
}
913
</script>
1014

1115
<template>
@@ -14,7 +18,7 @@ function changeVideo() {
1418
Multiple YouTube Players
1519
</NuxtLink>
1620
<div>
17-
<ScriptYouTubePlayer :video-id="videoid" above-the-fold>
21+
<ScriptYouTubePlayer :video-id="videoid" above-the-fold class="w-[640px] h-[360px]">
1822
<template #awaitingLoad>
1923
<div class="text-lg top-5 absolute left-10">
2024
Nuxt Nation 2023: Daniel Roe - A New Nuxt - Release of Nuxt v3.8
@@ -31,5 +35,12 @@ function changeVideo() {
3135
>
3236
change video
3337
</UButton>
38+
39+
<UButton
40+
class="ml-5"
41+
@click="changeVideoFallback"
42+
>
43+
change video needs fallback
44+
</UButton>
3445
</div>
3546
</template>

0 commit comments

Comments
 (0)