Gravatars: Add option to force default avatar display
We would like to see an admin option to force the display of the default gravatar icon.
This can be implemented very easily be adding the following parameter to the gravatar url: &forcedefault=1
Now If I choose for example wavatar as the default gravatar icon in the display options, and then check this new "force" option, the above url parameter will be appended to the url, resulting in the display of the wavatar wven if the user uploaded a picture in gravatar.
This way offensive/annoying custom gravatars can be avioded.
#4 Updated by Felix Schäfer about 11 years ago
Eric Davis wrote:
If it's in the official Gravatar API we can use it.
As I said, can't find it mentioned here http://en.gravatar.com/site/implement/images/
Redmine is using my fork of the Gravatar plugin already so we can add features to it that we need.
I know :-)
#6 Updated by Felix Schäfer about 11 years ago
Sebastian M. wrote:
I asked the gravatar devs to add it to the official api.
Please update this ticket once they have, I'll take care of adding the feature.
Meanwhile, could you tell me wich line I have to edit to add that parameter in the sourcecode?
Here's a diff that should (i.e. non-tested) work:
diff --git a/vendor/plugins/gravatar/lib/gravatar.rb b/vendor/plugins/gravatar/lib/gravatar.rb index 9af1fed..43e2c9e 100644 --- a/vendor/plugins/gravatar/lib/gravatar.rb +++ b/vendor/plugins/gravatar/lib/gravatar.rb @@ -35,6 +35,9 @@ module GravatarHelper # Whether or not to display the gravatars using HTTPS instead of HTTP :ssl => false, + + # Whether or not to display user's custom gravatars or only the generated ones + :forcedefault => 1, } # The methods that will be made available to your views. @@ -73,7 +76,7 @@ module GravatarHelper options[:default] = CGI::escape(options[:default]) unless options[:default].nil? returning gravatar_api_url(email_hash, options.delete(:ssl)) do |url| opts =  - [:rating, :size, :default].each do |opt| + [:rating, :size, :default, :forcedefault].each do |opt| unless options[opt].nil? value = h(options[opt]) opts << [opt, value].join('=')
#11 Updated by Sebastian M. over 10 years ago
Hmm does this mean nobody takes care of this ticket now? I successfully integrated Felix's patch, it works, so it should not be so difficult to integrate it into the admin options, shouldn't it? I am not a ruby coder, so unfortunately I can't do it myself. :/