summaryrefslogtreecommitdiffstats
path: root/ui/src/utils.ts
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-03-07 18:31:13 -0500
committerDessalines <tyhou13@gmx.com>2020-03-07 18:31:13 -0500
commitac280782b27b07e5282af03e329253503100ef99 (patch)
tree85cb2195686814650986d6d9c96eb6bf9d121c1b /ui/src/utils.ts
parent496c4e523c95ffad4b2749896f6c22409a2b3c3f (diff)
Iframely and pictshare backend mostly done.
Diffstat (limited to 'ui/src/utils.ts')
-rw-r--r--ui/src/utils.ts23
1 files changed, 15 insertions, 8 deletions
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 {