Additionally, you might want .gravatar-blank here.

If that data selector doesn't work, you might have to test after the next line (if (gravatar.attr('data-gravatar')) { ... } )