From: Dessalines Date: Fri, 3 Jan 2020 19:13:22 +0000 (-0500) Subject: Adding pictshare image thumbnailer. X-Git-Url: http://these/git/%7B%60%24%7BghostArchiveUrl%7D/%22%7Burl%7D/static/%7BlocalRss%7D?a=commitdiff_plain;h=a670096d53e841987a76e8afdf66e874e625b404;p=lemmy.git Adding pictshare image thumbnailer. - Fixes #377 --- diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index 8b4c1cb6..e5e71b65 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 b9da6cb6..a45abdca 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; + } +}