Instead of doing this at upload time, could this be a setable option in the album properties? To display the filename if theere is no caption present.