mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-05 15:02:37 +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}
|
blob={value.file}
|
||||||
alt={value.name}
|
alt={value.name}
|
||||||
fit={dimensions.fit}
|
fit={dimensions.fit}
|
||||||
width={dimensions.width}
|
width={Math.ceil(dimensions.width)}
|
||||||
height={dimensions.height}
|
height={Math.ceil(dimensions.height)}
|
||||||
on:load={handleLoad}
|
on:load={handleLoad}
|
||||||
on:error={handleError}
|
on:error={handleError}
|
||||||
on:loadstart={handleLoadStart}
|
on:loadstart={handleLoadStart}
|
||||||
|
@ -60,10 +60,10 @@ function parseImageTransform (accept: string, transform: string): ImageTransform
|
|||||||
image.dpr = parseFloat(value)
|
image.dpr = parseFloat(value)
|
||||||
break
|
break
|
||||||
case 'width':
|
case 'width':
|
||||||
image.width = parseFloat(value)
|
image.width = parseInt(value)
|
||||||
break
|
break
|
||||||
case 'height':
|
case 'height':
|
||||||
image.height = parseFloat(value)
|
image.height = parseInt(value)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -88,14 +88,13 @@ export async function handleImageGet (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!blob.contentType.startsWith('image/')) {
|
|
||||||
res.status(400).send()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const dpr = image.dpr === undefined || Number.isNaN(image.dpr) ? 1 : image.dpr
|
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 width =
|
||||||
const height = image.height === undefined || Number.isNaN(image.height) ? undefined : image.height * dpr
|
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 fit = image.fit ?? 'cover'
|
||||||
|
|
||||||
const tempDir = mkdtempSync(join(tmpdir(), 'image-'))
|
const tempDir = mkdtempSync(join(tmpdir(), 'image-'))
|
||||||
|
Loading…
Reference in New Issue
Block a user