From 912871d0ac994d8d675f9588893fbdbe2a0e76b0 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 3 Jan 2020 14:13:22 -0500 Subject: [PATCH] Adding pictshare image thumbnailer. - Fixes #377 --- ui/src/components/post-listing.tsx | 3 ++- ui/src/utils.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index 8b4c1cb68..e5e71b65e 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -27,6 +27,7 @@ import { getUnixTime, pictshareAvatarThumbnail, showAvatars, + imageThumbnailer, } from '../utils'; import { i18n } from '../i18next'; import { T } from 'inferno-i18next'; @@ -137,7 +138,7 @@ export class PostListing extends Component { > )} diff --git a/ui/src/utils.ts b/ui/src/utils.ts index b9da6cb64..a45abdcae 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -352,3 +352,14 @@ export function showAvatars(): boolean { !UserService.Instance.user ); } + +/// Converts to image thumbnail (only supports pictshare currently) +export function imageThumbnailer(url: string): string { + let split = url.split('pictshare'); + if (split.length > 1) { + let out = `${split[0]}pictshare/140x140${split[1]}`; + return out; + } else { + return url; + } +}