Optimize getFile function

Optimize getFile function by checking for getimagesize only on actual images files, based on extension