Skip to content

Commit eb6ac89

Browse files
committed
chore: refactor
1 parent 2e0619e commit eb6ac89

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/components/UploadcareImage.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import Image, { ImageProps } from 'next/image';
22
import React from 'react';
3+
import {
4+
PLACEHOLDER_SIZE_FALLBACK,
5+
PLACEHOLDER_SIZE_MULTIPLIER
6+
} from '../utils/constants';
37
import { getInt } from '../utils/helpers';
48
import { uploadcareLoader } from '../utils/loader';
59

@@ -12,7 +16,9 @@ const generateBlurDataUrl = (
1216
width: ImageProps['width']
1317
): string => {
1418
const imageWidth = getInt(width);
15-
const blurImageWidth = imageWidth ? Math.ceil(imageWidth * 0.01) : 10;
19+
const blurImageWidth = imageWidth
20+
? Math.ceil(imageWidth * PLACEHOLDER_SIZE_MULTIPLIER)
21+
: PLACEHOLDER_SIZE_FALLBACK;
1622
return uploadcareLoader({
1723
src: src,
1824
width: blurImageWidth,

src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ export const MAX_OUTPUT_JPEG_IMAGE_DIMENSION = 5000;
33
export const NOT_PROCESSED_EXTENSIONS = ['svg', 'gif'];
44
export const DEFAULT_PARAMS = ['format/auto', 'stretch/off', 'progressive/yes'];
55
export const DEFAULT_CDN_DOMAIN = 'ucarecdn.com';
6+
export const PLACEHOLDER_SIZE_MULTIPLIER = 0.01;
7+
export const PLACEHOLDER_SIZE_FALLBACK = 10;

0 commit comments

Comments
 (0)