Is it secure to open files while my operating system is connected to the internet?

How to know that after I open some a file (let’s say picture, movie or pdf from e.g. pendrive) it connects to the internet showing my IP?

Can I block it somehow in Windows and/or Linux not disconnecting from the internet?

Is it possible that I open the file offline and it send my IP online once I connect to the wi-fi again?

use firewall

i never heard or deal(ed) with file that talk to net after you open it (i talk about move, song or pic not setup wizard)

If you are completely paranoid, you can create an offline virtual machine, copy your file to the machine, and open it there. After that, delete your virtual machine.

However, in most cases, files shouldn’t simply connect to the internet since this requires additional code that is likely not contained in simple viewer software.