From ac280782b27b07e5282af03e329253503100ef99 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 7 Mar 2020 18:31:13 -0500 Subject: Iframely and pictshare backend mostly done. --- ui/src/utils.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'ui/src/utils.ts') diff --git a/ui/src/utils.ts b/ui/src/utils.ts index ea09cf96..27dbfb50 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -404,15 +404,22 @@ export function showAvatars(): boolean { ); } -/// 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/192${split[1]}`; - return out; - } else { - return url; +// Converts to image thumbnail +export function pictshareImage( + hash: string, + thumbnail: boolean = false +): string { + let root = `/pictshare`; + + // Necessary for other servers / domains + if (hash.includes('pictshare')) { + let split = hash.split('/pictshare/'); + root = `${split[0]}/pictshare`; + hash = split[1]; } + + let out = `${root}/${thumbnail ? '192/' : ''}${hash}`; + return out; } export function isCommentType(item: Comment | PrivateMessage): item is Comment { -- cgit v1.2.3