Skip to content

Commit a06c0cc

Browse files
aonnikovhaiodo
andauthored
fix: image preview not displayed (#8207)
Signed-off-by: Alexander Onnikov <[email protected]> Signed-off-by: Andrey Sobolev <[email protected]> Co-authored-by: Andrey Sobolev <[email protected]>
1 parent b5020fe commit a06c0cc

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

plugins/attachment-resources/src/components/AttachmentImagePreview.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@
131131
blob={value.file}
132132
alt={value.name}
133133
fit={dimensions.fit}
134-
width={dimensions.width}
135-
height={dimensions.height}
134+
width={Math.ceil(dimensions.width)}
135+
height={Math.ceil(dimensions.height)}
136136
on:load={handleLoad}
137137
on:error={handleError}
138138
on:loadstart={handleLoadStart}

services/datalake/pod-datalake/src/handlers/image.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ function parseImageTransform (accept: string, transform: string): ImageTransform
6060
image.dpr = parseFloat(value)
6161
break
6262
case 'width':
63-
image.width = parseFloat(value)
63+
image.width = parseInt(value)
6464
break
6565
case 'height':
66-
image.height = parseFloat(value)
66+
image.height = parseInt(value)
6767
break
6868
}
6969
})
@@ -88,14 +88,13 @@ export async function handleImageGet (
8888
return
8989
}
9090

91-
if (!blob.contentType.startsWith('image/')) {
92-
res.status(400).send()
93-
return
94-
}
95-
9691
const dpr = image.dpr === undefined || Number.isNaN(image.dpr) ? 1 : image.dpr
97-
const width = image.width === undefined || Number.isNaN(image.width) ? undefined : image.width * dpr
98-
const height = image.height === undefined || Number.isNaN(image.height) ? undefined : image.height * dpr
92+
const width =
93+
image.width === undefined || Number.isNaN(image.width) ? undefined : Math.min(Math.round(image.width * dpr), 2048)
94+
const height =
95+
image.height === undefined || Number.isNaN(image.height)
96+
? undefined
97+
: Math.min(Math.round(image.height * dpr), 2048)
9998
const fit = image.fit ?? 'cover'
10099

101100
const tempDir = mkdtempSync(join(tmpdir(), 'image-'))

0 commit comments

Comments
 (0)