fix: remove wrong urls
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
---
|
---
|
||||||
import type { ImageMetadata } from "astro";
|
import type { ImageMetadata } from "astro";
|
||||||
import { Picture as AstroImage } from "astro:assets";
|
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";
|
import { generateThumbHash, getExifData } from "@helpers/image";
|
||||||
interface Props {
|
interface Props {
|
||||||
src: ImageMetadata & { fsPath?: string, src?: string };
|
src: ImageMetadata & { fsPath?: string; src?: string };
|
||||||
alt: string;
|
alt: string;
|
||||||
pictureClass?: string;
|
pictureClass?: string;
|
||||||
class?: string;
|
class?: string;
|
||||||
@@ -16,20 +16,20 @@ interface Props {
|
|||||||
|
|
||||||
async function checkImage(image: ImageMetadata) {
|
async function checkImage(image: ImageMetadata) {
|
||||||
const src = image.src;
|
const src = image.src;
|
||||||
if(!src) return false;
|
if (!src) return false;
|
||||||
try {
|
try {
|
||||||
if (src.startsWith("/@fs") || src.startsWith("/_astro")) return true;
|
if (src.startsWith("/@fs") || src.startsWith("/_astro")) return true;
|
||||||
const res = await inferRemoteSize(src);
|
const res = await inferRemoteSize(src);
|
||||||
if (res.format) {
|
if (res.format) {
|
||||||
image.format = res.format;
|
image.format = res.format;
|
||||||
return true;
|
return true;
|
||||||
}else {
|
} else {
|
||||||
console.log("Failed to load: ", src);
|
console.log("Failed to load: ", src);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log("\n");
|
||||||
console.log("Failed to fetch: ", src);
|
console.log("Failed to fetch: ", src);
|
||||||
console.log(err)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ const {
|
|||||||
maxWidth,
|
maxWidth,
|
||||||
} = Astro.props;
|
} = Astro.props;
|
||||||
|
|
||||||
let thumbhash = hash && await generateThumbHash(image);
|
let thumbhash = hash && (await generateThumbHash(image));
|
||||||
const imageOk = await checkImage(image);
|
const imageOk = await checkImage(image);
|
||||||
|
|
||||||
let exif = imageOk && (await getExifData(image));
|
let exif = imageOk && (await getExifData(image));
|
||||||
@@ -85,5 +85,5 @@ const sizes = [
|
|||||||
.join(", ")}>
|
.join(", ")}>
|
||||||
<slot />
|
<slot />
|
||||||
</AstroImage>
|
</AstroImage>
|
||||||
) : undefined
|
) : undefined
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/content/photos/picos-de-europa/index.en.mdx
(Stored with Git LFS)
BIN
src/content/photos/picos-de-europa/index.en.mdx
(Stored with Git LFS)
Binary file not shown.
BIN
src/content/photos/picos-de-europa/index.mdx
(Stored with Git LFS)
BIN
src/content/photos/picos-de-europa/index.mdx
(Stored with Git LFS)
Binary file not shown.
Reference in New Issue
Block a user