cloudflare-next-intl 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export function ImgWithFallback({ originalSrc, ...imgProps }) {
|
|
4
|
+
const onError = (event) => {
|
|
5
|
+
const img = event.currentTarget;
|
|
6
|
+
if (originalSrc && img.src !== originalSrc && !img.src.endsWith(originalSrc)) {
|
|
7
|
+
img.srcset = "";
|
|
8
|
+
img.src = originalSrc;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
return _jsx("img", { ...imgProps, onError: onError });
|
|
12
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import NextImage, { getImageProps as nextGetImageProps } from "next/image";
|
|
3
3
|
import { getImageBlurSvg } from "./blur_svg.js";
|
|
4
|
+
import { ImgWithFallback } from "./img_with_fallback.js";
|
|
4
5
|
function pickVariant(entry, requestedWidth) {
|
|
5
6
|
if (!requestedWidth || !entry.variants || entry.variants.length === 0) {
|
|
6
7
|
return entry;
|
|
@@ -110,16 +111,9 @@ export default function Image(props) {
|
|
|
110
111
|
const { props: imgProps } = nextGetImageProps(resolved);
|
|
111
112
|
const primarySrc = variant?.src ?? String(imgProps.src);
|
|
112
113
|
const originalSrc = entry?.originalSrc;
|
|
113
|
-
const onError = (event) => {
|
|
114
|
-
const img = event.currentTarget;
|
|
115
|
-
if (originalSrc && img.src !== originalSrc && !img.src.endsWith(originalSrc)) {
|
|
116
|
-
img.srcset = "";
|
|
117
|
-
img.src = originalSrc;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
114
|
return (_jsxs("picture", { children: [alternates.map((source) => (_jsx("source", { type: source.type, sizes: imgProps.sizes, srcSet: imgProps.srcSet
|
|
121
115
|
? retargetSrcSet(imgProps.srcSet, primarySrc, source.src)
|
|
122
|
-
: source.src }, source.src))), _jsx(
|
|
116
|
+
: source.src }, source.src))), _jsx(ImgWithFallback, { ...imgProps, alt: imgProps.alt ?? "", originalSrc: originalSrc })] }));
|
|
123
117
|
}
|
|
124
118
|
export function getImageProps(props) {
|
|
125
119
|
const resolved = resolveProps(props);
|