diff options
author | Dessalines <tyhou13@gmx.com> | 2020-01-03 14:13:22 -0500 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-01-03 14:13:22 -0500 |
commit | a670096d53e841987a76e8afdf66e874e625b404 (patch) | |
tree | 1c553a2151dc39f149fd2ec9994a564c0ba6ceed /ui | |
parent | 747a8f5b96b10f56f14d7dad30764084e69d8cab (diff) |
Adding pictshare image thumbnailer.
- Fixes #377
Diffstat (limited to 'ui')
-rw-r--r-- | ui/src/components/post-listing.tsx | 3 | ||||
-rw-r--r-- | ui/src/utils.ts | 11 |
2 files changed, 13 insertions, 1 deletions
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<PostListingProps, PostListingState> { > <img class="mx-2 mt-1 float-left img-fluid thumbnail rounded" - src={post.url} + src={imageThumbnailer(post.url)} /> </span> )} 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; + } +} |