diff --git a/anatomy/static/js/anatomy.js b/anatomy/static/js/anatomy.js index 06cf37ee..493c17b3 100644 --- a/anatomy/static/js/anatomy.js +++ b/anatomy/static/js/anatomy.js @@ -599,10 +599,20 @@ async function setUpDicom3d(element) { // Prepare imageIds: ensure remote URLs are usable by dicom-image-loader (wadouri:) + // but avoid forcing wadouri: for standard web images (png/jpg/etc) because + // the dicom parser will fail when given non-DICOM files. For such images + // return the raw URL so the appropriate web-image loader can handle them. const imageIds = images.map((url) => { url = url.trim(); - // if it's already a scheme we pass through; otherwise treat as wadouri - if (/^(wadouri:|base64:|data:)/i.test(url)) return url; + // if it's already a scheme we pass through + if (/^(wadouri:|base64:|data:|http:|https:)/i.test(url)) return url; + + // If the URL looks like a regular web image, don't treat it as DICOM + if (url.match(/\.(png|jpe?g|gif|bmp|webp)$/i)) { + return url; + } + + // default: treat as wadouri (likely a DICOM file) return `wadouri:${url}`; });