diff --git a/app/soapbox/components/media_gallery.js b/app/soapbox/components/media_gallery.js
index 3eda57795..149aa3740 100644
--- a/app/soapbox/components/media_gallery.js
+++ b/app/soapbox/components/media_gallery.js
@@ -147,15 +147,30 @@ class Item extends React.PureComponent {
if (attachment.get('type') === 'unknown') {
const filename = truncateFilename(attachment.get('remote_url'), MAX_FILENAME_LENGTH);
- return (
-
- );
+ var re = /(?:\.([^.]+))?$/;
+ const type = re.exec(filename)[1]; // e.g. "pdf"
+ if(type === 'pdf') {
+ return (
+
+
+
+ );
+ } else {
+ return (
+
+ );
+ }
} else if (attachment.get('type') === 'image') {
const previewUrl = attachment.get('preview_url');
diff --git a/app/soapbox/features/account_gallery/components/media_item.js b/app/soapbox/features/account_gallery/components/media_item.js
index 3a59ca55c..c81f08534 100644
--- a/app/soapbox/features/account_gallery/components/media_item.js
+++ b/app/soapbox/features/account_gallery/components/media_item.js
@@ -9,12 +9,15 @@ import { decode } from 'blurhash';
import { isIOS } from 'soapbox/is_mobile';
import { getSettings } from 'soapbox/actions/settings';
import StillImage from 'soapbox/components/still_image';
+import { truncateFilename } from 'soapbox/utils/media';
const mapStateToProps = state => ({
autoPlayGif: getSettings(state).get('autoPlayGif'),
displayMedia: getSettings(state).get('displayMedia'),
});
+const MAX_FILENAME_LENGTH = 45;
+
export default @connect(mapStateToProps)
class MediaItem extends ImmutablePureComponent {
@@ -104,9 +107,22 @@ class MediaItem extends ImmutablePureComponent {
let thumbnail = '';
let icon;
-
if (attachment.get('type') === 'unknown') {
- // Skip
+ const filename = truncateFilename(attachment.get('remote_url'), MAX_FILENAME_LENGTH);
+ var re = /(?:\.([^.]+))?$/;
+ const type = re.exec(filename)[1]; // e.g. "pdf"
+ if(type === 'pdf') {
+ thumbnail = (
+
+ );
+ } else {
+ // skip
+ }
} else if (attachment.get('type') === 'image') {
const focusX = attachment.getIn(['meta', 'focus', 'x']) || 0;
const focusY = attachment.getIn(['meta', 'focus', 'y']) || 0;
@@ -156,6 +172,15 @@ class MediaItem extends ImmutablePureComponent {
{fileExtension}
);
+ } else if (attachment.get('type') === 'pdf') {
+ thumbnail = (
+
+ );
}
if (!visible) {