forked from FoundKeyGang/FoundKey
parent
bab1dc1d97
commit
9c106022ae
1 changed files with 4 additions and 2 deletions
|
@ -4,15 +4,17 @@ import config from '../config';
|
||||||
export default function(file: IDriveFile, thumbnail = false): string {
|
export default function(file: IDriveFile, thumbnail = false): string {
|
||||||
if (file == null) return null;
|
if (file == null) return null;
|
||||||
|
|
||||||
|
const isImage = file.contentType && file.contentType.startsWith('image/');
|
||||||
|
|
||||||
if (file.metadata.withoutChunks) {
|
if (file.metadata.withoutChunks) {
|
||||||
if (thumbnail) {
|
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 {
|
} else {
|
||||||
return file.metadata.webpublicUrl || file.metadata.url;
|
return file.metadata.webpublicUrl || file.metadata.url;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (thumbnail) {
|
if (thumbnail) {
|
||||||
return `${config.drive_url}/${file._id}?thumbnail`;
|
return isImage ? `${config.drive_url}/${file._id}?thumbnail` : null;
|
||||||
} else {
|
} else {
|
||||||
return `${config.drive_url}/${file._id}?web`;
|
return `${config.drive_url}/${file._id}?web`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue