Skip to content

Commit e7d19a5

Browse files
authored
Merge pull request #375 from diggsweden/fix-image-optimazation
Fixing linting
2 parents a0ef1d4 + f39807a commit e7d19a5

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

components/global/CustomImage/index.tsx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ interface CustomImageProps {
1414
const isNextStatic = (url: string) =>
1515
typeof url != "string" || !url.startsWith("/uploads");
1616

17-
const imageWidths = [128, 256, 384, 640, 828, 1080, 1200, 1920, 3840];
18-
1917
export const CustomImage: FC<CustomImageProps> = ({
2018
image,
2119
sizes,
@@ -46,7 +44,7 @@ export const CustomImage: FC<CustomImageProps> = ({
4644
sizes={
4745
sizes
4846
? sizes
49-
: `(max-width: 640px) 100vw, (max-width: 1200px) 50vw, 20vw`
47+
: "(max-width: 640px) 100vw, (max-width: 1200px) 50vw, 20vw"
5048
}
5149
loading="lazy"
5250
/>
@@ -57,21 +55,17 @@ export const CustomImage: FC<CustomImageProps> = ({
5755
? image.url
5856
: (env("MEDIA_BASE_URL") || "") + image.url;
5957

60-
const srcset = imageWidths
61-
.map((w) => `${src}?w=${w}&q=${75} ${w}w`)
62-
.join(", ");
63-
6458
return (
65-
<picture>
66-
<source srcSet={srcset} type={image.mime} sizes={sizes} />
67-
<img
68-
className={className}
69-
src={`${src}?w=${384}&q=${75}`}
70-
width={image.width || ""}
71-
height={image.height || ""}
72-
alt={image.alt || ""}
73-
loading="lazy"
74-
/>
75-
</picture>
59+
<Image
60+
src={src}
61+
width={Number(image.width) || 384}
62+
height={Number(image.height) || 200}
63+
className={className ? className : ""}
64+
alt={image.alt || ""}
65+
sizes={
66+
sizes || "(max-width: 640px) 100vw, (max-width: 1200px) 50vw, 20vw"
67+
}
68+
priority
69+
/>
7670
);
7771
};

0 commit comments

Comments
 (0)