mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-05 06:49:30 +00:00
fix: image preview not displayed (#8207)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> Signed-off-by: Andrey Sobolev <haiodo@gmail.com> Co-authored-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
b5020fed12
commit
a06c0cc5b7
@ -131,8 +131,8 @@
|
||||
blob={value.file}
|
||||
alt={value.name}
|
||||
fit={dimensions.fit}
|
||||
width={dimensions.width}
|
||||
height={dimensions.height}
|
||||
width={Math.ceil(dimensions.width)}
|
||||
height={Math.ceil(dimensions.height)}
|
||||
on:load={handleLoad}
|
||||
on:error={handleError}
|
||||
on:loadstart={handleLoadStart}
|
||||
|
@ -60,10 +60,10 @@ function parseImageTransform (accept: string, transform: string): ImageTransform
|
||||
image.dpr = parseFloat(value)
|
||||
break
|
||||
case 'width':
|
||||
image.width = parseFloat(value)
|
||||
image.width = parseInt(value)
|
||||
break
|
||||
case 'height':
|
||||
image.height = parseFloat(value)
|
||||
image.height = parseInt(value)
|
||||
break
|
||||
}
|
||||
})
|
||||
@ -88,14 +88,13 @@ export async function handleImageGet (
|
||||
return
|
||||
}
|
||||
|
||||
if (!blob.contentType.startsWith('image/')) {
|
||||
res.status(400).send()
|
||||
return
|
||||
}
|
||||
|
||||
const dpr = image.dpr === undefined || Number.isNaN(image.dpr) ? 1 : image.dpr
|
||||
const width = image.width === undefined || Number.isNaN(image.width) ? undefined : image.width * dpr
|
||||
const height = image.height === undefined || Number.isNaN(image.height) ? undefined : image.height * dpr
|
||||
const width =
|
||||
image.width === undefined || Number.isNaN(image.width) ? undefined : Math.min(Math.round(image.width * dpr), 2048)
|
||||
const height =
|
||||
image.height === undefined || Number.isNaN(image.height)
|
||||
? undefined
|
||||
: Math.min(Math.round(image.height * dpr), 2048)
|
||||
const fit = image.fit ?? 'cover'
|
||||
|
||||
const tempDir = mkdtempSync(join(tmpdir(), 'image-'))
|
||||
|
Loading…
Reference in New Issue
Block a user