Optimize getFile function

By checking for getimagesize only on actual images files, based on extension