From 5e1ddb552ee9fc8972c9537eee62cddc93a24f42 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 14 Mar 2021 15:53:00 -0400 Subject: [PATCH] feat: only runs adminThumbnail func if image type --- docs/upload/overview.mdx | 5 +++++ src/uploads/getThumbnail.ts | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/upload/overview.mdx b/docs/upload/overview.mdx index 9b976a557f..55cfad3692 100644 --- a/docs/upload/overview.mdx +++ b/docs/upload/overview.mdx @@ -133,6 +133,11 @@ const Media = { } ``` + + Note:
+ If you specify a function to return an admin thumbnail, but your upload is not an image file type (for example, PDF or TXT) your function will not be used. Instead, Payload will display its generic file upload graphic. +
+ ### Uploading Files diff --git a/src/uploads/getThumbnail.ts b/src/uploads/getThumbnail.ts index ca6adde81b..eb513ab51c 100644 --- a/src/uploads/getThumbnail.ts +++ b/src/uploads/getThumbnail.ts @@ -15,11 +15,11 @@ const getThumbnail = (collection: CollectionConfig, doc: Record filename, } = doc; - if (typeof adminThumbnail === 'function') { - return adminThumbnail({ doc }); - } - if (isImage(mimeType as string)) { + if (typeof adminThumbnail === 'function') { + return adminThumbnail({ doc }); + } + if (sizes?.[adminThumbnail]?.filename) { return `${staticURL}/${sizes[adminThumbnail].filename}`; }