From 0be605b41d08be976824e04f3df40550ecb0140d Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 10 Nov 2025 11:11:00 +0000 Subject: [PATCH] Enhance DICOM image URL handling to support standard web images without forcing wadouri scheme --- anatomy/static/js/anatomy.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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}`; });