Skip to content

Commit

Permalink
Merge pull request #3 from ggmanuilov/master
Browse files Browse the repository at this point in the history
Added ability to specify image size.
  • Loading branch information
andrewvasilchuk committed Sep 2, 2019
2 parents 1118008 + ef946b9 commit 3910374
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default {
| alt | `false` | String | `"Video alternative image"` | Alternative text of the preview image |
| buttonLabel | `false` | String | `"Play video"` | `aria-label` attribute value of the play button. It improves a11y. |
| aspectRatio | `false` | String | `"16:9"` | Aspect ratio. It helps to save proportions of the video on different container sizes. |
| size | `false` | String | `"hqdefault"` | Video size. Available variants 'mqdefault', 'sddefault', 'hqdefault', 'maxresdefault'.|

## ⚙️ Events

Expand Down
1 change: 1 addition & 0 deletions dist/vue-lazy-youtube-video.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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: "hqdefault",
validator: value =>
[
"default",
"mqdefault",
"sddefault",
"hqdefault",
"maxresdefault"
].indexOf(value) !== -1
}
},
data() {
Expand Down

0 comments on commit 3910374

Please sign in to comment.