@decocms/apps 1.9.0 → 1.9.1
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.
|
@@ -88,6 +88,20 @@ function optimizeShopify(originalSrc: string, width: number, height?: number): s
|
|
|
88
88
|
export function getOptimizedMediaUrl(opts: OptimizationOptions): string {
|
|
89
89
|
const { originalSrc, width, height, fit } = opts;
|
|
90
90
|
|
|
91
|
+
// Defensive: an upstream CMS payload occasionally has missing/null image
|
|
92
|
+
// fields. Crashing the entire React tree on `undefined.startsWith` would
|
|
93
|
+
// take down the whole page. Return an empty string so the resulting
|
|
94
|
+
// `<img>` is rendered with no src — the browser shows the broken-image
|
|
95
|
+
// placeholder and SSR completes cleanly.
|
|
96
|
+
if (typeof originalSrc !== "string" || originalSrc.length === 0) {
|
|
97
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
|
|
98
|
+
console.warn(
|
|
99
|
+
`[Image] getOptimizedMediaUrl called with empty/undefined src — rendering empty src instead of crashing.`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return "";
|
|
103
|
+
}
|
|
104
|
+
|
|
91
105
|
if (originalSrc.startsWith("data:")) {
|
|
92
106
|
return originalSrc;
|
|
93
107
|
}
|
|
@@ -126,6 +140,10 @@ export function getSrcSet(
|
|
|
126
140
|
fit?: FitOptions,
|
|
127
141
|
factors: number[] = FACTORS,
|
|
128
142
|
): string | undefined {
|
|
143
|
+
if (typeof originalSrc !== "string" || originalSrc.length === 0) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
|
|
129
147
|
const entries: string[] = [];
|
|
130
148
|
|
|
131
149
|
for (const factor of factors) {
|