mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
I'm not sure what's the history behind splitting the logic between speech and non-speech, but currently, doing `${thumbnail}?quality=${quality}&height=${height}&width=${width}` will result in a redirect to `${THUMBNAIL_CDN_URL}s:${width}:${height}/quality:80/plain/${thumbnail}` (hardcoded to 80). That's the same CDN url we use for non-speech, so might as do the same for all images to avoid the redirect.
25 lines
593 B
JavaScript
25 lines
593 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) {
|
|
return `${THUMBNAIL_CDN_URL}s:${width}:${height}/quality:${quality}/plain/${thumbnail}`;
|
|
}
|
|
}
|