diff --git a/plugins/attachment-resources/src/components/AttachmentImagePreview.svelte b/plugins/attachment-resources/src/components/AttachmentImagePreview.svelte index 53db098025..0e3286bc60 100644 --- a/plugins/attachment-resources/src/components/AttachmentImagePreview.svelte +++ b/plugins/attachment-resources/src/components/AttachmentImagePreview.svelte @@ -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} diff --git a/services/datalake/pod-datalake/src/handlers/image.ts b/services/datalake/pod-datalake/src/handlers/image.ts index d69d7c0430..a40c17dc58 100644 --- a/services/datalake/pod-datalake/src/handlers/image.ts +++ b/services/datalake/pod-datalake/src/handlers/image.ts @@ -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-'))