Snippet for own (gr)avatars

This is essentially how gravatar service works.

Your code has no knowledge if particular email has gravatar associated with it. The only way would be to query gravatar API and store if there is gravatar available (and re-query for updates) for each email and resulting functionality will quickly snowball past just having that redirect there.

A little more practical tweak might be implementing lazy loading for gravatars, so they aren’t loaded until visitor actually scrolls to them.