diff --git a/src/components/Image.astro b/src/components/Image.astro
index 67d3e5b..50e8c77 100644
--- a/src/components/Image.astro
+++ b/src/components/Image.astro
@@ -1,7 +1,7 @@
---
import type { ImageMetadata } from "astro";
import { Picture as AstroImage } from "astro:assets";
-import { inferRemoteSize } from "astro/assets/utils";
+import { inferRemoteSize, inferSize } from "astro/assets/utils";
import { getProcessedImage } from "@helpers/image";
interface Props {
src: ImageMetadata & { fsPath?: string; src?: string };
@@ -15,11 +15,13 @@ interface Props {
thumbnail?: boolean;
}
-async function checkImage(image: ImageMetadata):Promise<({height:number,width:number}|undefined)> {
+async function checkImage(
+ image: ImageMetadata,
+): Promise<{ height: number; width: number } | undefined> {
const src = typeof image === "string" ? image : image.src;
- if (!src) return ;
+ if (!src) return;
try {
- if (src.startsWith("/@fs") || src.startsWith("/_astro")) return;
+ if (src.startsWith("/@fs") || src.startsWith("/_astro")) return {};
const res = await inferRemoteSize(src);
if (res.format) {
image.format = res.format;
@@ -27,11 +29,11 @@ async function checkImage(image: ImageMetadata):Promise<({height:number,width:nu
} else {
console.log("Failed to load: ", src);
}
- return ;
+ return;
} catch (err) {
console.log("\n");
console.log("Failed to fetch: ", src);
- return ;
+ return;
}
}
@@ -81,11 +83,10 @@ const sizes = thumbnail
alt={alt}
data-thumbhash={thumbhash}
data-exif={JSON.stringify(exif)}
- inferSize={true}
width={imageOk?.width}
height={imageOk?.height}
pictureAttributes={{
- class: `${hash ? "block h-full relative" : ""} ${loader ? "thumb" : ""} ${pictureClass}`,
+ class: `${hash ? "block h-full relative" : ""} ${loader ? "thumb" : ""} ${pictureClass}`,
}}
class={`${Astro.props.class} h-full w-full`}
widths={sizes.map((size) => size.width)}
@@ -94,5 +95,7 @@ const sizes = thumbnail
.join(", ")}>