From 9c106022ae850ad33653d8fdfc8231e02006a8d7 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 1 Feb 2019 21:37:34 +0900 Subject: [PATCH] Fix #3871 (#4082) --- src/misc/get-drive-file-url.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/misc/get-drive-file-url.ts b/src/misc/get-drive-file-url.ts index 6ab7bfdb1..90c3f2442 100644 --- a/src/misc/get-drive-file-url.ts +++ b/src/misc/get-drive-file-url.ts @@ -4,15 +4,17 @@ import config from '../config'; export default function(file: IDriveFile, thumbnail = false): string { if (file == null) return null; + const isImage = file.contentType && file.contentType.startsWith('image/'); + if (file.metadata.withoutChunks) { if (thumbnail) { - return file.metadata.thumbnailUrl || file.metadata.webpublicUrl || file.metadata.url; + return file.metadata.thumbnailUrl || file.metadata.webpublicUrl || (isImage ? file.metadata.url : null); } else { return file.metadata.webpublicUrl || file.metadata.url; } } else { if (thumbnail) { - return `${config.drive_url}/${file._id}?thumbnail`; + return isImage ? `${config.drive_url}/${file._id}?thumbnail` : null; } else { return `${config.drive_url}/${file._id}?web`; }