Handle gif, jpg, jpeg and png, files appropriately