Optimize getFiles function

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