Targetting an image in an iframe NextJS

Viewed 10

I need to target an image tag in an iframe with CSS in a NextJS app, I tried this solution https://stackoverflow.com/a/15101795/19306314 but it doesn't display the image at all and the path just downloads the php file show_image.php and does nothing else.

Here's code:

const path = image?.file_url.replace('ipfs://', 'https://ipfs.io/ipfs/')
const src = isImageUrl(image?.file_url) ? `/show_image.php?src=${path}` : path
return (
    <iframe key={index}
      title={image?.name}
      src={src}
      allow='fullscreen fullscreen; picture-in-picture;'
      sandbox='allow-same-origin'
     >
       Your browser does not support iframe.
       <a href={path} target='_blank' rel='noreferrer'>See content here </a>
      </iframe>
)

show_image.php is in my public directory at the root of the project, here's the code in it:

<img src="<?php echo $_GET['src']; ?>" style='width:100%' />
0 Answers
Related