fix: remove wrong urls

This commit is contained in:
Max Richter
2025-10-22 22:45:25 +02:00
parent bce3ea609e
commit e8bf992712
3 changed files with 11 additions and 11 deletions

View File

@@ -1,10 +1,10 @@
---
import type { ImageMetadata } from "astro";
import { Picture as AstroImage } from "astro:assets";
import { inferRemoteSize } from 'astro/assets/utils';
import { inferRemoteSize } from "astro/assets/utils";
import { generateThumbHash, getExifData } from "@helpers/image";
interface Props {
src: ImageMetadata & { fsPath?: string, src?: string };
src: ImageMetadata & { fsPath?: string; src?: string };
alt: string;
pictureClass?: string;
class?: string;
@@ -16,20 +16,20 @@ interface Props {
async function checkImage(image: ImageMetadata) {
const src = image.src;
if(!src) return false;
if (!src) return false;
try {
if (src.startsWith("/@fs") || src.startsWith("/_astro")) return true;
const res = await inferRemoteSize(src);
if (res.format) {
image.format = res.format;
return true;
}else {
} else {
console.log("Failed to load: ", src);
}
return false;
} catch (err) {
console.log("\n");
console.log("Failed to fetch: ", src);
console.log(err)
return false;
}
}
@@ -43,7 +43,7 @@ const {
maxWidth,
} = Astro.props;
let thumbhash = hash && await generateThumbHash(image);
let thumbhash = hash && (await generateThumbHash(image));
const imageOk = await checkImage(image);
let exif = imageOk && (await getExifData(image));
@@ -85,5 +85,5 @@ const sizes = [
.join(", ")}>
<slot />
</AstroImage>
) : undefined
) : undefined
}

Binary file not shown.

Binary file not shown.