From f7279c1d49ae0881fc5603a79f9b4f99be7f0d15 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 8 Dec 2020 13:51:59 -0500 Subject: [PATCH] use cdn for thumbnails --- .env.defaults | 1 + config.js | 1 + ui/component/fileThumbnail/view.jsx | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env.defaults b/.env.defaults index 975646bac..7505c9733 100644 --- a/.env.defaults +++ b/.env.defaults @@ -14,6 +14,7 @@ WELCOME_VERSION=1.0 # Custom Site info DOMAIN=lbry.tv URL=https://lbry.tv +THUMBNAIL_CDN_URL=https://cached-proxy.vanwanet.com/?url= # UI SITE_TITLE=lbry.tv diff --git a/config.js b/config.js index 59121e9ae..367d84387 100644 --- a/config.js +++ b/config.js @@ -16,6 +16,7 @@ const config = { DOMAIN: process.env.DOMAIN, SHARE_DOMAIN_URL: process.env.SHARE_DOMAIN_URL, URL: process.env.URL, + THUMBNAIL_CDN_URL: process.env.THUMBNAIL_CDN_URL, SITE_TITLE: process.env.SITE_TITLE, SITE_NAME: process.env.SITE_NAME, SITE_DESCRIPTION: process.env.SITE_DESCRIPTION, diff --git a/ui/component/fileThumbnail/view.jsx b/ui/component/fileThumbnail/view.jsx index d13829050..21ad1f4a0 100644 --- a/ui/component/fileThumbnail/view.jsx +++ b/ui/component/fileThumbnail/view.jsx @@ -1,5 +1,6 @@ // @flow import type { Node } from 'react'; +import { THUMBNAIL_CDN_URL } from 'config'; import React from 'react'; import FreezeframeWrapper from './FreezeframeWrapper'; import Placeholder from './placeholder.png'; @@ -37,7 +38,13 @@ function FileThumbnail(props: Props) { ); } - const url = thumbnail || (hasResolvedClaim ? Placeholder : ''); + let url = thumbnail || (hasResolvedClaim ? Placeholder : ''); + // @if TARGET='web' + // Pass image urls through a compression proxy + if (thumbnail && !thumbnail.includes('https://spee.ch')) { + url = `${THUMBNAIL_CDN_URL}${encodeURIComponent(thumbnail)}`; + } + // @endif return (