@@ -201,10 +201,10 @@ const ObjectIdDisplay: React.FC<{
201201 ) ;
202202} ;
203203
204- const Base64ImagePreview : React . FC < {
205- base64String : string ;
204+ const ImagePreview : React . FC < {
205+ imageUrl : string ;
206206 searchRegex : RegExp | null ;
207- } > = ( { base64String , searchRegex } ) => {
207+ } > = ( { imageUrl , searchRegex } ) => {
208208 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
209209 const [ previewPos , setPreviewPos ] = useState < { x : number ; y : number } | null > ( null ) ;
210210 const iconRef = useRef < HTMLSpanElement > ( null ) ;
@@ -248,7 +248,7 @@ const Base64ImagePreview: React.FC<{
248248 title = "Click to collapse back to icon"
249249 >
250250 < span className = "text-emerald-700 dark:text-emerald-300" > "
251- { searchRegex ? highlightText ( base64String , searchRegex ) : base64String } "
251+ { searchRegex ? highlightText ( imageUrl , searchRegex ) : imageUrl } "
252252 </ span >
253253 </ span >
254254 ) ;
@@ -281,7 +281,7 @@ const Base64ImagePreview: React.FC<{
281281 } }
282282 >
283283 < img
284- src = { base64String }
284+ src = { imageUrl }
285285 alt = "Preview"
286286 className = "max-w-[200px] max-h-[200px] object-contain rounded bg-slate-100 dark:bg-slate-900"
287287 />
@@ -475,8 +475,11 @@ const JsonNode: React.FC<{
475475 ) ;
476476 }
477477
478- if ( nodeValue . startsWith ( "data:image/png;base64," ) ) {
479- return < Base64ImagePreview base64String = { nodeValue } searchRegex = { searchRegex } /> ;
478+ const isBase64Image = nodeValue . startsWith ( "data:image/" ) ;
479+ const isUrlImage = / ^ h t t p s ? : \/ \/ .+ \. ( p n g | j p e ? g | g i f | s v g | w e b p ) ( \? .* ) ? $ / i. test ( nodeValue ) ;
480+
481+ if ( isBase64Image || isUrlImage ) {
482+ return < ImagePreview imageUrl = { nodeValue } searchRegex = { searchRegex } /> ;
480483 }
481484
482485 return < span className = "text-emerald-700 dark:text-emerald-300" > "
0 commit comments