Gravatar

http://lifeofajackass.com/wp-content/plugins/downloads-manager/img/icons/default.gif download: Gravatar (61.36KB)
added: 12/03/2009
clicks: 3554
description: A small .NET control that allows you to pull in a users Gravatar.

For those that have been here before you’ll notice a huge change in the code. I went ahead and did this as a control class. There are 4 properties to be set: EMAIL, RATING, SIZE, ICONSET

You can access the code from SVN or download the project above.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Gravatar
{
    public partial class Gravatar : UserControl
    {
        /// <summary>
        /// Base URL for the Gravatar image
        /// </summary>
        private string BaseURL = "http://www.gravatar.com/avatar/{0}?d={1}&s={2}&r={3}";

        public Gravatar()
        {
            InitializeComponent();
        }

        #region Properties, very ugly
        /// <summary>
        /// Email Property
        /// </summary>
        string theEmail;

        public string email
        {
            get { return theEmail; }
            set
            {
                theEmail = value;
                UpdateGravatar();
            }
        }

        /// <summary>
        /// Rating Property
        /// </summary>
        public enum Rating
        {
            g, pg, r, x
        }

        private Rating theRating;

        public Rating rating
        {
            get { return theRating; }
            set
            {
                theRating = value;
                UpdateGravatar();
            }
        }

        /// <summary>
        /// Icon Set Property
        /// </summary>
        public enum IconSet
        {
            identicon, monsterid, wavatar
        }

        private IconSet theIconSet;

        public IconSet iconset
        {
            get { return theIconSet; }
            set
            {
                theIconSet = value;
                UpdateGravatar();
            }
        }

        /// <summary>
        /// Size Property
        /// </summary>
        int theSize = 80;
        public int size
        {
            get { return theSize; }
            set
            {
                theSize = value;
                UpdateGravatar();
            }
        }
        #endregion

        /// <summary>
        /// Small MD5 Function
        /// </summary>
        /// <param name="theEmail"></param>
        /// <returns>Hash of the email address passed.</returns>
        public string MD5(string theEmail)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider md5Obj =
                new System.Security.Cryptography.MD5CryptoServiceProvider();

            byte[] bytesToHash = System.Text.Encoding.ASCII.GetBytes(theEmail);

            bytesToHash = md5Obj.ComputeHash(bytesToHash);

            string strResult = "";

            foreach (byte b in bytesToHash)
            {
                strResult += b.ToString("x2");
            }

            return strResult;
        }

        /// <summary>
        /// Update the Gravatar anytime an attribute is changed
        /// </summary>
        private void UpdateGravatar()
        {
            //hash the email address
            string hE = MD5(theEmail);
            //format our url to the Gravatar
            string tU = string.Format(BaseURL, hE, iconset, size, rating);
            //resize our control (I'm not using AutoSize for a reason)
            this.Size = new System.Drawing.Size(size, size);
            imgGravatar.Size = new System.Drawing.Size(size, size);
            //load the Gravatar into our picture box. (maybe later I will load this
            //into memory and paint it to the control instead.
            imgGravatar.ImageLocation = tU;
        }
    }
}

Popularity: unranked [?]

78 Responses to “Gravatar”

  1. pingback pingback:
    1
    GravatarGet: Update | Life Of A Jackass

    [...] GravatarGet [...]

    Reply to this comment.
  2. Avatarericka
    2

    nao consigo colocar minha foto como faço para obter ajuda

    Reply to this comment.
  3. Avatarmartin
    3

    How did you start it

    Reply to this comment.
  4. AvatarJah'Bara
    4
  5. Avatarbonus casino
    5

    Post and article very interesting. Thanks for this post
    webmaster: Bonus Casino – I migliori casino online con bonus in italiano.

    Reply to this comment.
  6. Avatarsherief_professional retouching
    6

    please for all of you tell me..
    do you think which one is more better
    to be a programmer and know more than language
    or to be a mind and ideas creator .and peoples programm it for you …

    Reply to this comment.
  7. AvatarDora
    7

    I’m getting you. It actually worked quite well I must say. Good Job!

    Reply to this comment.
  8. Avatarmd:abusayedroni
    8
  9. Avatarweb hosting reviews
    9

    Thanks!
    I Think I am going to change to library too.

    Reply to this comment.
  10. AvatarSolicitors Northamptonshire
    10

    Awesome job, extremely useful thanks!!

    Reply to this comment.
  11. Avatartamiflu
    11

    wow thanks! probably i’ll chage to library as well

    Reply to this comment.
  12. Avatarabc
    12

    grate job!very useful thing and thank u!

    Reply to this comment.
  13. AvatarJohn
    13

    i love the name of this blog. Hilarious

    Reply to this comment.
  14. Avataralbuterol
    14

    It works!!!
    Thank you.

    To sherief_professional retouching – it depends. For me is better to be a codder

    Reply to this comment.
  15. Avatarдоверительное управление
    15

    Thanks for the C sharp version

    Best Regards,
    Доверительное Управление

    Reply to this comment.
  16. AvatarKonferenser
    16

    Excellent explanation. Works perfectly. Got confused initially with a couple of steps,realized i missed out on them!

    Thanks so much, this came in very handy to me, really needed this at the time..

    Reply to this comment.
  17. pingback pingback:
    17
    GravatarGet Life Of A Jackass | fix my credit

    [...] GravatarGet Life Of A Jackass Posted by root 1 hour 7 minutes ago (http://lifeofajackass.com) The library is available in c and vb net it is very basic stuff however there are a lot of people i think i am going to change to library too reply to this comment 2009 from web powered by wordpress twitter widget pro Discuss  |  Bury |  News | GravatarGet Life Of A Jackass [...]

    Reply to this comment.
  18. AvatarEmail Marketing Solutions
    18

    i think this is a good idea. i love the work. i hope you keep churning out interesting things like this.

    Reply to this comment.
  19. pingback pingback:
    19
    GravatarGet Life Of A Jackass | debt solutions

    [...] GravatarGet Life Of A Jackass Posted by root 3 days ago (http://lifeofajackass.com) I think i am going to change to library too reply to this comment xhtml you can use these tags lt a href quot quot title quot quot gt lt abbr title quot quot gt lt acronym title quot quot gt lt b gt 2009 from web powered by wordpress twitter widget pro go Discuss  |  Bury |  News | GravatarGet Life Of A Jackass [...]

    Reply to this comment.
  20. AvatarSearchMarketing
    20

    Excellent write up and thanks for posting your code. I would never have thought to do it like this.

    Reply to this comment.
  21. Avatarbukmacher
    21

    good job, thanks for the code

    Reply to this comment.
  22. Avatarjohnstevens
    22

    п»ї
    Agree with you! Nice read.
    Great post, thank you|
    Thanks post and site very nice…. very interesting.
    Thanks for the link.
    Nice! Thanks to author this post|
    I have got it all worked out already by rereading ypur suggestion and this reply again.

    Reply to this comment.
  23. AvatarBuzz News
    23

    I was looking for something like this. A C# version. Thank you very much for sharing it with us. By the way I love your blog. Keep up the good work.

    Reply to this comment.
  24. AvatarSEO Services
    24

    I will check it out! Excellent coding. Its very good that you actually came up with the idea of doing it by using c#. Thanks a lot for sharing.

    Reply to this comment.
  25. Avatarwebhosting guy
    25

    Great work dude, your post worth reading, it contains quite healthy information about coding.

    Reply to this comment.
  26. Avatarhosting guy
    26

    Very interesting post, it worth a lot for me. You provide such important information in such impressive way.

    Reply to this comment.
  27. Avatardigital channel
    27

    i am just curious, is it possible to pull website favicon and expand it into a user’s gravatar? tnx

    Reply to this comment.
  28. Avatarkonferens
    28

    Gravatars are just so convenient… plus you couldn’t make them easier to set up once you sign up for an account. The other day I had to tell some friends that visited my site to get on here and get some Gravatars made… which spurred me to make a post about it to get people a bit more informed. I’m sure if your server was overloaded, this was the likely culprit (haha yeah, I wish).

    Reply to this comment.
  29. AvatarLovelinks
    29

    Thanks for the coding. It helped me a lot to understand. I use vb.net and this explains a lot. Thanks again. By the way I love your blog. Keep it up. Cheers !

    Reply to this comment.
  30. Avatarbusiness hosting monster
    30

    Interesting post, at last i found some thing use on some blog, thanks dude, i like the way you describe this coding change.

    Reply to this comment.
  31. Avatarshared web site hosting
    31

    Thanks for your blog.Very cool stuff.

    Reply to this comment.
  32. AvatarCheap Office Supplies
    32

    Genius coding. It s really good work actually. im sure this effort will not be wasted. It already has served a lot of people. Thanks a lot for this mate! Cheers

    Reply to this comment.
  33. Avatartamiflu
    33

    thanks a lot! it helped me

    Reply to this comment.
  34. AvatarTents
    34

    Awesome. Just what I was looking for. Appreciate it immensely. Cheers

    Reply to this comment.
  35. AvatarWeb Hosting Philippines
    35

    Excellent explanation. Works perfectly. Got confused initially with a couple of steps,realized i missed out on them!

    Thanks so much, this came in very handy to me, really needed this at the time..

    Reply to this comment.
  36. AvatarAlex
    36

    Do you think which one is more better
    to be a programmer and know more than language
    or to be a mind and ideas creator

    Reply to this comment.
  37. AvatarAndrew Croft
    37

    Thanks a lot, I am just starting out at all this stuff and this has really helped.

    Reply to this comment.
  38. AvatarHome detox
    38

    You have explained it well… I have bookmarked this site for future reference… Keep going.

    Reply to this comment.
  39. AvatarZack
    39

    It helped me a lot to understand. I use vb.net and this explains a lot. Thanks again. By the way I love your blog. Keep it up. Cheers !

    Reply to this comment.
  40. AvatarTents
    40

    My friend told me about this site, and I came to take a look. This is great, we were looking for something like this. I think this will help us immensely. Thank you for sharing.

    Reply to this comment.
  41. AvatarGas Fires
    41

    Thank for the help. I made some changes to my site the other day, and noticed…where the heck are my gravatars? Had to figure out how to put back on. The best help was including the css info.

    Reply to this comment.
  42. AvatarPool Table Store
    42

    Awesome. I too had some problems with my gravatars recently. Got hem figured out now. Thanks bunch. Cheers. Keep up the awesome work.

    Reply to this comment.
  43. AvatarClip In Hair Extensions
    43

    Just what I wanted. Thank god. Where were you guys all this time :) Thanks again.

    Reply to this comment.
  44. Avatarlucy
    44

    Excellent explanation. Works perfectly. Got confused initially with a couple of steps,realized i missed out on them!

    Lucy

    Reply to this comment.
  45. AvatarStock Clearance
    45

    I discovered Gravatar months ago – I’m frequently surprised how many sites automatically pick them up, it’s like fire and forget, I’ve got two set up depending on which email address I use.

    Reply to this comment.
  46. AvatarAlex_R
    46

    Thanks! Where is my VS ^)

    Reply to this comment.
  47. AvatarSafety Boots
    47

    I would love to use this addon, but it doesnt work for me! I installed it (didn’t replace index.php because of version 1.6.0. Also, I replaced in image_template.html with . But there is no image showing up in my comments!!

    Reply to this comment.
  48. AvatarSold out concert tickets
    48

    That’s awesome. Just the coding I needed. Thanks a bunch for it. Appreciate it. Cheers

    Reply to this comment.
  49. AvatarLap dancing jobs
    49

    Awesome stuff. I really love the blog. Gravatars have always been my problem. Thanks a bunch for the explanation and code. Cheers

    Reply to this comment.
  50. AvatarSugoi Clothing
    50

    I think its finally getting there for me, once i got the right combination of settings… thanks for the default link to a gravatar. I had to keep the first option of the email address blank for it to show my gravatar though, not sure why…Thanks for posting!

    Reply to this comment.
  51. AvatarOnline Pharmacy Store
    51

    thanks! very useful! i needed this coding

    Reply to this comment.
  52. AvatarLMS
    52

    I would love to use this add-on, but it does not work for me! I installed it (didn’t replace index.php because of version 1.6.0. Also, I replaced in image_template.html with . But no image shows up in my comments!

    Reply to this comment.
  53. AvatarJay @ Car Cleaning Products
    53

    I am always really excited to watch where Gravatar expands beyond the blog commenting space. EditGrid seems to have seen the upsides of using Gravatar for profiles. They don’t have to worry about writing and maintaining a cropper, file storage, serving infrastructure, backups, etc. All they have to worry about is their core business: making a killer web based spreadsheet application.

    Reply to this comment.
  54. Avatarcar hire uk
    54

    The other day I had to tell some friends that visited my site to get on here and get some Gravatars made… which spurred me to make a post about it to get people a bit more informed.

    Reply to this comment.
  55. pingback pingback:
    55
    Les préoccupations d’un chef de projet Internet… » Gravatar : votre avatar universel

    [...] .Net [...]

    Reply to this comment.
  56. Avatarautomotive blog
    56

    That’s awesome. Just the coding I needed. Thanks a bunch for it. Appreciate it. Cheers

    Reply to this comment.
  57. AvatarOnline Pharmacy Store
    57

    i agree with you! thanks

    Reply to this comment.
  58. AvatarJohn Cook
    58

    Downloaded latest version, thanks a lot

    Reply to this comment.
  59. AvatarGet Netted
    59

    Downloaded latest version, thanks a lot

    Thanks so much, this came in very handy to me, really needed this at the time..

    Reply to this comment.
  60. AvatarSolicitors
    60

    Great post, Downloading now!!! Thanks!

    Reply to this comment.
  61. Avatarloans
    61

    I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.

    Reply to this comment.
  62. Avatarkurye
    62

    GravatarGet :Life Of A Jackass great article thank you.

    Reply to this comment.
  63. Avatarbestmed
    63

    Get access to online drugstores that offer brand name and generic drugs and prescription medications. Now you can safely buy medication from licensed online Pharmacies at guaranteed low prices. Online prescription medication has never been so safe or easy.

    Reply to this comment.
  64. Avatarweb hosting philippines
    64

    nice post. thanks.. very informative post. i’ll try this too.

    Reply to this comment.
  65. AvatarBillig Fliegen
    65

    Seams to be a great piece of software and I will give it a try – thank you for sharing it :-)

    Reply to this comment.
  66. Avatarcar hire Murcia Airport
    66

    I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.

    Reply to this comment.
  67. AvatarAuto Versicherung
    67

    “The download link has been updated for the new library.” I guess I have to update my libary – nice work.

    Reply to this comment.
  68. Avatarconcrete garages
    68

    Hey, the post is awesome. But my problem is to asociate the gravatar image to an author image in my index.php Wordpress blog. I don’t know the correct sintaxis to do this. Have you any sugerence? Thanks a lot!!!

    Reply to this comment.
  69. AvatarBodybuilding Supplements
    69

    I would love to use this addon, but it doesnt work for me! I installed it (didn’t replace index.php because of version 1.6.0. Also, I replaced in image_template.html with . But there is no image showing up in my comments!!

    Reply to this comment.
  70. Avataryouth
    70

    Great job on with this addon. I have been looking for this for a while.

    Reply to this comment.
  71. AvatarPHP Form
    71

    Thanks! thats perfect!

    Reply to this comment.
  72. Avatarbukmacherski marco
    72

    best ive ever seen on bukmacherzy

    Reply to this comment.
  73. Avatarcomputer repairs
    73

    Works great here, many thanks!!

    Reply to this comment.
  74. pingback pingback:
    74
    Add Gravatar support to your blog comments | Cre8ive Commando

    [...] .Net Gravatar Implementation [...]

    Reply to this comment.
  75. pingback pingback:
    75
    Linkit Blog » Gravatar

    [...] .Net [...]

    Reply to this comment.
  76. AvatarGuest
    76

    Its interesting,good work.

    Reply to this comment.
  77. AvatarSEO
    77

    many thanks!!

    Reply to this comment.
  78. Avatarluxury boutique hotels singapore
    78

    thanks for this nice post

    Reply to this comment.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>