Not sure if I’ve understand this correctly but you should be able to check which tab is currently open by looking at $_GET['tab']
- upload new tab =
type
- from url =
type_url
- gallery =
gallery
- media library =
library
So you could wrap your code inside
if ( $_GET['tab'] != 'type' ) // do stuff