detect if file is image before load