From bdd50770be67779b540f26c450f7108cb0c0104f Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Sun, 20 Jul 2025 01:28:36 +0200 Subject: [PATCH] fix: enhance image loading logic to handle static paths when sockets are unavailable --- src/components/Images.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/Images.js b/src/components/Images.js index cda2834..cad40d3 100644 --- a/src/components/Images.js +++ b/src/components/Images.js @@ -52,8 +52,13 @@ class Images extends Component { pics.push(bildId); this.loadPic(this.props.fullscreenOpen ? 'large' : 'medium',bildId,newMainPic); }else{ - pics.push(bildId); - this.loadPic(this.props.fullscreenOpen ? 'large' : 'medium',bildId,newMainPic); + // For prerender or when sockets unavailable, use static path + if (!this.props.socket && !this.props.socketB) { + pics.push(`/assets/images/prod${bildId}.jpg`); + } else { + pics.push(bildId); + this.loadPic(this.props.fullscreenOpen ? 'large' : 'medium',bildId,newMainPic); + } } }else{ if(window.tinyPicCache[bildId]){ @@ -62,8 +67,13 @@ class Images extends Component { pics.push(window.mediumPicCache[bildId]); this.loadPic('tiny',bildId,newMainPic); }else{ - pics.push(null); - this.loadPic('tiny',bildId,pics.length-1); + // For prerender or when sockets unavailable, use static path + if (!this.props.socket && !this.props.socketB) { + pics.push(`/assets/images/prod${bildId}.jpg`); + } else { + pics.push(null); + this.loadPic('tiny',bildId,pics.length-1); + } } } } @@ -75,6 +85,9 @@ class Images extends Component { } loadPic = (size,bildId,index) => { + // Skip loading if sockets are not available (e.g., during prerender) + if (!this.props.socketB) return; + this.props.socketB.emit('getPic', { bildId, size }, (res) => { if(res.success){ const url = URL.createObjectURL(new Blob([res.imageBuffer], { type: 'image/jpeg' }));