Merge pull request #190 from WardPearce/fix/thumbnail-load-times
Fix/thumbnail load times
This commit is contained in:
@@ -249,7 +249,7 @@
|
||||
>
|
||||
<media-provider>
|
||||
{#if !audioMode}
|
||||
<media-poster class="vds-poster" src={getBestThumbnail(data.video.videoThumbnails)}
|
||||
<media-poster class="vds-poster" src={getBestThumbnail(data.video.videoThumbnails, 1251, 781)}
|
||||
></media-poster>
|
||||
{/if}
|
||||
</media-provider>
|
||||
|
||||
@@ -135,8 +135,17 @@ export function peerJsOptions(): PeerOptions {
|
||||
};
|
||||
}
|
||||
|
||||
export function getBestThumbnail(images: Image[] | null): string | null {
|
||||
export function getBestThumbnail(
|
||||
images: Image[] | null,
|
||||
maxWidthDimension: number = 480,
|
||||
maxHeightDimension = 360): string | null {
|
||||
if (images && images.length > 0) {
|
||||
images = images.filter(image => image.width < maxWidthDimension && image.height < maxHeightDimension);
|
||||
|
||||
if (images.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
images.sort((a, b) => {
|
||||
return (b.width * b.height) - (a.width * a.height);
|
||||
});
|
||||
@@ -145,4 +154,4 @@ export function getBestThumbnail(images: Image[] | null): string | null {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user