mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-10-28 08:15:47 -04:00
fix automatic image blurring
This commit is contained in:
@@ -11,18 +11,19 @@ export type ImageProps = ComponentPropsWithoutRef<typeof NextImage> & {
|
|||||||
inline?: boolean; // don't wrap everything in a `<div>` block
|
inline?: boolean; // don't wrap everything in a `<div>` block
|
||||||
};
|
};
|
||||||
|
|
||||||
const Image = ({ src, height, width, quality, inline, className, ...rest }: ImageProps) => {
|
const Image = ({ src, height, width, quality, placeholder, inline, className, ...rest }: ImageProps) => {
|
||||||
const constrainWidth = (width?: number | `${number}`) => {
|
const constrainWidth = (width?: number | `${number}`) => {
|
||||||
if (!width) return MAX_WIDTH;
|
if (!width) return MAX_WIDTH;
|
||||||
|
|
||||||
return Math.min(typeof width === "string" ? parseInt(width, 10) : width, MAX_WIDTH);
|
return Math.min(typeof width === "string" ? parseInt(width, 10) : width, MAX_WIDTH);
|
||||||
};
|
};
|
||||||
|
|
||||||
const imageProps = {
|
const imageProps: ImageProps = {
|
||||||
src,
|
src,
|
||||||
height,
|
height,
|
||||||
width: constrainWidth(width || (src as StaticImageData).width),
|
width: constrainWidth(width || (src as StaticImageData).width),
|
||||||
quality: quality || 75,
|
quality: quality || 75,
|
||||||
|
placeholder: placeholder || (typeof src === "string" ? "empty" : "blur"),
|
||||||
...rest,
|
...rest,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user