twaddington / django-gravatar

Essential Gravatar support for Django. Features helper methods, templatetags and a full test suite!
MIT License
151 stars 33 forks source link

Add a default parameter. #25

Closed skorokithakis closed 4 years ago

skorokithakis commented 7 years ago

There are services that generate "default" user icons based on their name, email, etc. The current GRAVATAR_DEFAULT_IMAGE setting cannot use these services.

I propose two things:

  1. The gravatar template tag be changed to accept a "default image URL" argument.
  2. The GRAVATAR_DEFAULT_IMAGE be changed to accept either a string (the current behavior), or a callable which will be called with the tag's parameters and will return a URL for the fallback image. That way, we can specify a function that will accept email/size/etc and will return a URL for the default image for the user.
twaddington commented 7 years ago

Thanks @skorokithakis I think those are both reasonable suggestions. I'm curious to know more about your particular use case. Are you using another library to generate the default user icons?

skorokithakis commented 7 years ago

Yes, exactly. I'm using http://avatars.adorable.io/, which needs a random parameter to generate deterministic avatars. I also wanted to use Robohash, but since Gravatar strips query parameters, I optimized the other way and used Robohash falling back to Gravatar when a Gravatar exists.

twaddington commented 7 years ago

Cool, yeah, I like this idea so long as it can be kept reasonably generic. Are you interested in submitting a pull request?

skorokithakis commented 7 years ago

Sure, I can take a stab at it soon. I've mostly implemented it for my service anyway.

twaddington commented 7 years ago

That'd be awesome. I haven't done much Django development lately but I could take a stab at it if need be.

coler-j commented 6 years ago

image