Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-bulldogs-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@uppy/thumbnail-generator": patch
---

Make tiny/small thumbnails look better by not scaling them to cover the entire grid item
15 changes: 11 additions & 4 deletions packages/@uppy/thumbnail-generator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,23 @@ export default class ThumbnailGenerator<
}

if (width != null) {
let targetWidth = width
// Thumbnail shouldn’t be enlarged / upscaled, only reduced.
// If img is already smaller than width/height, leave it as is.
if (img.width < width) targetWidth = img.width

return {
width,
height: Math.round(width / aspect),
width: targetWidth,
height: Math.round(targetWidth / aspect),
}
}

if (height != null) {
let targetHeight = height
if (img.height < height) targetHeight = img.height
return {
width: Math.round(height * aspect),
height,
width: Math.round(targetHeight * aspect),
height: targetHeight,
}
}

Expand Down