How to create a switch Node that recognizes if a texture is connected to the node input?
Here are three ways to do it:

Python Nodes API: with Python nodes like mentioned before, you can create a smart/dynamic node, that can change values depending on Python properties, like if an image is inserted or not

if you don't want to use PyNodes, you can use drivers, here's a simple driver that does what you need (change &quot;Image Texture&quot; in drivers panel to the name of your Image Texture Node):

if you plan to have such functionality inside a node group, you could set a chosen default value for a socket (a negative value would work in this case), then if nothing is connected to the socket, it would have the default value, which you compare and detect, if something is then connected to the socket, that would change its value, now the compare would return 0, it all works out, because Image Texture Node won't produce a negative value.