lbry-desktop/ui/util/thumbnail.js
infinite-persistence 8d399d6a2c
Revert accidental commit from ody repo
"[Comments] Batch resolve #7236"

This reverts commit b8cc60697b, reversing
changes made to e3791aefdc.
2021-10-11 09:43:58 +08:00

29 lines
778 B
JavaScript

// @flow
import { THUMBNAIL_CDN_URL } from 'config';
const THUMBNAIL_HEIGHT = 220;
const THUMBNAIL_WIDTH = 390;
const THUMBNAIL_QUALITY = 85;
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;
if (!THUMBNAIL_CDN_URL || !thumbnail) {
return thumbnail;
}
if (thumbnail && !thumbnail.includes('https://spee.ch')) {
return `${THUMBNAIL_CDN_URL}s:${width}:${height}/quality:${quality}/plain/${thumbnail}`;
}
if (thumbnail && thumbnail.includes('https://spee.ch')) {
return `${thumbnail}?quality=${quality}&height=${height}&width=${width}`;
}
}