Merge pull request #190 from WardPearce/fix/thumbnail-load-times

Fix/thumbnail load times
This commit is contained in:
Ward
2024-05-01 09:01:58 +12:00
committed by GitHub
2 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -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>
+11 -2
View File
@@ -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;
}
}
}