Check if group input node was passed a value, optional default value
By default an image texture with no associated file will output a completely black value. You can use this to drive the alpha value of your background, using a "Math" node set to "Greater Than 0" in order to have full transparency when there is no image texture and zero transparency when there is an associated image texture.