diff --git a/.env.defaults b/.env.defaults index 67f86633f..b641b9879 100644 --- a/.env.defaults +++ b/.env.defaults @@ -22,7 +22,9 @@ THUMBNAIL_CDN_URL=https://thumbnails.odycdn.com/optimize/ THUMBNAIL_CARDS_CDN_URL=https://cards.odycdn.com/ LOCALE_API=https://api.odysee.com/legal/requirements THUMBNAIL_HEIGHT=220 +THUMBNAIL_HEIGHT_MOBILE=506 THUMBNAIL_WIDTH=390 +THUMBNAIL_WIDTH_MOBILE=900 THUMBNAIL_QUALITY=85 THUMBNAIL_CDN_SIZE_LIMIT_BYTES=5242880 WELCOME_VERSION=1.0 diff --git a/config.js b/config.js index 4dc0bf12a..15c5c1b7f 100644 --- a/config.js +++ b/config.js @@ -27,7 +27,9 @@ const config = { THUMBNAIL_CDN_URL: process.env.THUMBNAIL_CDN_URL, THUMBNAIL_CARDS_CDN_URL: process.env.THUMBNAIL_CARDS_CDN_URL, THUMBNAIL_HEIGHT: process.env.THUMBNAIL_HEIGHT, + THUMBNAIL_HEIGHT_MOBILE: process.env.THUMBNAIL_HEIGHT_MOBILE, THUMBNAIL_WIDTH: process.env.THUMBNAIL_WIDTH, + THUMBNAIL_WIDTH_MOBILE: process.env.THUMBNAIL_WIDTH_MOBILE, THUMBNAIL_QUALITY: process.env.THUMBNAIL_QUALITY, THUMBNAIL_CDN_SIZE_LIMIT_BYTES: process.env.THUMBNAIL_CDN_SIZE_LIMIT_BYTES, SITE_TITLE: process.env.SITE_TITLE, diff --git a/ui/component/fileThumbnail/view.jsx b/ui/component/fileThumbnail/view.jsx index 7008e1a7c..718acc709 100644 --- a/ui/component/fileThumbnail/view.jsx +++ b/ui/component/fileThumbnail/view.jsx @@ -1,10 +1,18 @@ // @flow import type { Node } from 'react'; +import { + THUMBNAIL_WIDTH, + THUMBNAIL_WIDTH_MOBILE, + THUMBNAIL_HEIGHT, + THUMBNAIL_HEIGHT_MOBILE, + THUMBNAIL_QUALITY, + MISSING_THUMB_DEFAULT, +} from 'config'; +import { useIsMobile } from 'effects/use-screensize'; import { getImageProxyUrl, getThumbnailCdnUrl } from 'util/thumbnail'; import React from 'react'; import FreezeframeWrapper from './FreezeframeWrapper'; import Placeholder from './placeholder.png'; -import { MISSING_THUMB_DEFAULT } from 'config'; import classnames from 'classnames'; import Thumb from './thumb'; @@ -28,6 +36,7 @@ function FileThumbnail(props: Props) { const hasResolvedClaim = claim !== undefined; const isGif = thumbnail && thumbnail.endsWith('gif'); + const isMobile = useIsMobile(); React.useEffect(() => { if (!hasResolvedClaim && uri && !passedThumbnail) { @@ -53,7 +62,12 @@ function FileThumbnail(props: Props) { if (isGif) { url = getImageProxyUrl(thumbnail); // Note: the '!allowGifs' case is handled in Freezeframe above. } else { - url = getThumbnailCdnUrl({ thumbnail }); + url = getThumbnailCdnUrl({ + thumbnail, + width: isMobile ? THUMBNAIL_WIDTH_MOBILE : THUMBNAIL_WIDTH, + height: isMobile ? THUMBNAIL_HEIGHT_MOBILE : THUMBNAIL_HEIGHT, + quality: THUMBNAIL_QUALITY, + }); } } // @endif