fix: enhance image loading logic to handle static paths when sockets are unavailable
This commit is contained in:
@@ -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' }));
|
||||
|
||||
Reference in New Issue
Block a user