2020-12-15 19:54:35 +01:00
|
|
|
// @flow
|
|
|
|
import { THUMBNAIL_CDN_URL } from 'config';
|
|
|
|
|
2021-03-04 19:38:01 +01:00
|
|
|
const THUMBNAIL_HEIGHT = 220;
|
|
|
|
const THUMBNAIL_WIDTH = 390;
|
|
|
|
const THUMBNAIL_QUALITY = 100;
|
2020-12-15 19:54:35 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
thumbnail: ?string,
|
|
|
|
height?: number,
|
|
|
|
width?: number,
|
|
|
|
quality?: number,
|
|
|
|
};
|
|
|
|
|
|
|
|
export function getThumbnailCdnUrl(props: Props) {
|
|
|
|
const { thumbnail, height = THUMBNAIL_HEIGHT, width = THUMBNAIL_WIDTH, quality = THUMBNAIL_QUALITY } = props;
|
|
|
|
|
2021-06-30 19:43:41 +02:00
|
|
|
if (!THUMBNAIL_CDN_URL || !thumbnail || thumbnail.includes('https://thumbnails.lbry.com')) {
|
2020-12-15 19:54:35 +01:00
|
|
|
return thumbnail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thumbnail && !thumbnail.includes('https://spee.ch')) {
|
2021-06-28 22:02:34 +02:00
|
|
|
return `${THUMBNAIL_CDN_URL}s:${width}:${height}/quality:${quality}/plain/${thumbnail}`;
|
2020-12-15 19:54:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (thumbnail && thumbnail.includes('https://spee.ch')) {
|
|
|
|
return `${thumbnail}?quality=${quality}&height=${height}&width=${width}`;
|
|
|
|
}
|
|
|
|
}
|