Skip to content

Commit

Permalink
feat: add size prop
Browse files Browse the repository at this point in the history
Add ability to specify desired size of thumbnail
  • Loading branch information
andrewvasilchuk committed Mar 22, 2020
1 parent 4b441bc commit c9a45e1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/VueLazyYoutubeVideo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<template v-if="!isVideoLoaded">
<picture>
<source
:srcset="`https://i.ytimg.com/vi_webp/${id}/hqdefault.webp`"
:srcset="`https://i.ytimg.com/vi_webp/${id}/${size}.webp`"
type="image/webp"
>
<img
class="y-video__media"
:src="`https://i.ytimg.com/vi/${id}/hqdefault.jpg`"
:src="`https://i.ytimg.com/vi/${id}/${size}.jpg`"
:alt="alt"
>
</picture>
Expand Down Expand Up @@ -54,6 +54,18 @@ export default {
const pattern = /^\d+:\d+$/;
return pattern.test(value);
}
},
size: {
type: String,
default: "maxresdefault",
validator: value =>
[
"default",
"mqdefault",
"sddefault",
"hqdefault",
"maxresdefault"
].indexOf(value) !== -1
}
},
data() {
Expand Down

0 comments on commit c9a45e1

Please sign in to comment.