Skip to content

Commit

Permalink
feat: only runs adminThumbnail func if image type
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikrut committed Mar 14, 2021
1 parent 521b49a commit 5e1ddb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/upload/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ const Media = {
}
```

<Banner>
<strong>Note:</strong><br/>
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.
</Banner>

### Uploading Files

<Banner type="warning">
Expand Down
8 changes: 4 additions & 4 deletions src/uploads/getThumbnail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const getThumbnail = (collection: CollectionConfig, doc: Record<string, unknown>
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}`;
}
Expand Down

0 comments on commit 5e1ddb5

Please sign in to comment.