Optimize getFile to check for imagesize only on images files, based on extension