]> Untitled Git - lemmy.git/commitdiff
Adding pictshare image thumbnailer.
authorDessalines <tyhou13@gmx.com>
Fri, 3 Jan 2020 19:13:22 +0000 (14:13 -0500)
committerDessalines <tyhou13@gmx.com>
Fri, 3 Jan 2020 19:13:22 +0000 (14:13 -0500)
- Fixes #377

ui/src/components/post-listing.tsx
ui/src/utils.ts

index 8b4c1cb684511c5464cc6734f5fb4432d698c62b..e5e71b65ee7811b35172952ca61e19914e16aa4c 100644 (file)
@@ -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>
         )}
index b9da6cb6467b721e210864bfb290da0277604bcb..a45abdcae6b9faea7ce9cbc5cdf975074d907120 100644 (file)
@@ -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;
+  }
+}