File tree Expand file tree Collapse file tree 3 files changed +33
-10
lines changed Expand file tree Collapse file tree 3 files changed +33
-10
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,29 @@ export default function DocImage({
16
16
return null ;
17
17
}
18
18
19
- // Next.js Image component only supports images from the public folder
20
- // or from a remote server with properly configured domain
19
+ // Handle external images early - pass through without processing
21
20
if ( src . startsWith ( 'http' ) ) {
22
- // eslint-disable-next-line @next/next/no-img-element
23
- return < img src = { src } { ...props } /> ;
21
+ // Use provided props or defaults for external images
22
+ const width = typeof propsWidth === 'number'
23
+ ? propsWidth
24
+ : typeof propsWidth === 'string'
25
+ ? parseInt ( propsWidth , 10 ) || 800
26
+ : 800 ;
27
+ const height = typeof propsHeight === 'number'
28
+ ? propsHeight
29
+ : typeof propsHeight === 'string'
30
+ ? parseInt ( propsHeight , 10 ) || 600
31
+ : 600 ;
32
+
33
+ return (
34
+ < DocImageClient
35
+ src = { src }
36
+ imgPath = { src } // For external images, imgPath should be the same as src
37
+ width = { width }
38
+ height = { height }
39
+ { ...props }
40
+ />
41
+ ) ;
24
42
}
25
43
26
44
// If the image src is not an absolute URL, we assume it's a relative path
Original file line number Diff line number Diff line change @@ -30,11 +30,12 @@ export function DocImageClient({
30
30
31
31
// For external images or invalid dimensions, fall back to regular img tag
32
32
if ( src . startsWith ( 'http' ) || ! isValidDimensions ) {
33
- const handleClick = ( e : React . MouseEvent ) => {
34
- // If Ctrl/Cmd+click, open image in new tab
35
- if ( e . ctrlKey || e . metaKey ) {
36
- window . open ( imgPath , '_blank' , 'noreferrer' ) ;
37
- return ;
33
+ const handleClick = ( ) => {
34
+ // Always open image in new tab
35
+ const url = src . startsWith ( 'http' ) ? src : imgPath ;
36
+ const newWindow = window . open ( url , '_blank' ) ;
37
+ if ( newWindow ) {
38
+ newWindow . opener = null ; // Security: prevent opener access
38
39
}
39
40
} ;
40
41
Original file line number Diff line number Diff line change @@ -27,7 +27,11 @@ export function ImageLightbox({
27
27
const handleClick = ( e : React . MouseEvent ) => {
28
28
// If Ctrl/Cmd+click, open image in new tab
29
29
if ( e . ctrlKey || e . metaKey ) {
30
- window . open ( imgPath , '_blank' , 'noreferrer' ) ;
30
+ const url = src . startsWith ( 'http' ) ? src : imgPath ;
31
+ const newWindow = window . open ( url , '_blank' ) ;
32
+ if ( newWindow ) {
33
+ newWindow . opener = null ; // Security: prevent opener access
34
+ }
31
35
return ;
32
36
}
33
37
// Normal click - open lightbox
You can’t perform that action at this time.
0 commit comments