A couple weeks ago I made a WordPress plugin to generate unique monsters for each commenter. Don Park came up with the original idea for representing users with geometric shapes. Since I already had the framework in place I thought I’d make a WordPress plugin for the original geometric Identicons. If you want to visually represent users (but maybe you don’t like monsters so much?) then this plugin is for you.
So what is an Identicon? It’s a randomly generated assortment of shapes that is specific to a commenter’s email (or if you prefer IP address). Identicons allow visual representations of commenters without requiring any external sites or user interactions. With 40 possible shapes (about 70 with inversions) in 3 possible positions, around 8000 distinguishable colors and four different rotations for each part, there should be several billion possible shape combinations which, even with the increasing chance of overlap with each additional user, should be quite enough for almost any blog.
Features
- Dynamically generated avatars for each commenter
- Consistently themed geometric icons
- Consistent on any blog
- Gravatar support
- Theme edits no longer necessary
Current Version:
Installation instructions:
Unzip wp_identicon.zip
. Upload wp_identicon.php and the identicon
folder. Make sure the identicon
folder is writable. If your unzipping program creates a wp_identicon folder please only upload the contents (wp_identicon.php
and the identicon
folder). That should be it. Identicons should now appear next to your commenter’s names.
You can adjust the background and foreground colors, the number of squares in and the size of the identicons in the Identicon Control Panel. You can also clear the Identicon image cache in the control panel.
Configuration:
- Identicon Size in Pixels
- How many pixels high and wide you want your Identicons. 35 by 35 seems like a decent compromise between compactness and clarity but they should remain mostly clear at any reasonable size.
- Number of Squares
- Number of shape blocks to build Identicon out of. Don Parks uses 3 by 3. I kind of like 4 by 4 myself. More than 4 starts to get a bit cluttered but can be interesting.
- Background colors
- The color of the background (empty part) of the Identicon. Personally I really like when the background matches the surroundings and the identicon appears to blend into it. Setting this to 0,0,0 makes the background transparent (what I’m using here) but IE6 does not like transparency in PNG’s and just fills the background with grey. If you know the R,G,B values of your background then you could set them directly here or you can put in a range of colors (like 1-255,255,255 to get backgrounds ranging from blue to light blue to white).
- Foreground colors
- The color of the foreground (colored part) of the Identicon. If this is 1-255,1-255,1-255 you will get Identicons of all the possible R,G,B colors. If you want only a certain color you could set the R,G,B values here (like 255,0,0 for only red Identicons) or you can put in a range of colors (like 1-255,255,255 to get Identicons ranging from blue to light blue to white).
- CSS Styling
- This is not in the Options menu. You can edit the CSS styling by adjusting the
style.css
file of your current theme. Identicons can be selected byimg.identicon
. A good start might be to addimg.identicon{float:left; margin-right:3px;}
to the bottom of yourstyle.css
.
For Advanced Users:
You can add CSS for img.identicon
in your theme’s style.css
. For even more control, you can disable the automatic placement in the Identicon Control Panel and add an identicon to any comment with identicon_build($comment->comment_author_email, $comment->comment_author);
. For example, find the comments.php
of your current theme (it should be in the folder wp-content/themes/[currentThemeName]/
). Open it up and look for something similar to foreach ($comments as $comment)
. Inside this loop there should be code that displays the comment author’s name or metadata like <p class="comment-author">
or <p class="comment-metadata">
. Just before all this enter:<?php if (function_exists(identicon_build)) echo identicon_build($comment->comment_author_email, $comment->comment_author); ?>
If you would prefer to base the Identicons on the commentor’s IP address instead of the commentor’s email just replace $comment->comment_author_email
in the above with $comment->comment_author_IP
.
icoguo has kindly translated the install instructions to Chinese and Tai has translated them to Japanese although these are a bit outdated since version 0.51.
If any of this is unclear just let me know in the comments and I’ll do my best to guide you through it.
Change Log:
- v2.0 12-10-2014:
-
v1.02 5-6-2008:
- Fixed WP 2.5+ built-in avatars when
$id_or_email
not email
- Fixed WP 2.5+ built-in avatars when
-
v1.01 5-2-2008:
- Fixed WP 2.5+ built-in avatars and gravatar support
-
v1.0 5-1-2008:
- Fixed automatically adding identicons to sidebar in single posts bug
- Supports WP 2.5+ built-in avatars
-
v0.62 2-14-2008:
- Added Recent Comment (with Identicons) Widget
- Deals with nested directories
-
v0.56 1-27-2007:
- Fixed manual identicon global problem (Thanks again to Anton)
-
v0.55 1-27-2007:
- Fixed gravatar option (Thanks Anton)
-
v0.51 1-9-2007:
- Added custom random number generator
- Monsters now consistent across servers
- Added greyscale option (nice for B&W themes)
- Added auto placement option
- Added gravatar support
- Obscured filenames
- Clarified options page
- Changed get_settings to get_option
- Fixed bug in random number generator seed
- Changed download link to WordPress Extends
-
v0.2 2-6-2007:
- Switched to heading/distance shape representation
- Added a bunch of shapes
- Added transparency
- Added option to choose number of pieces in Identicon (I’m partial to 4×4)
- Added height and width attributes to img for accessibility
- v0.1 1-31-2007:
- Implemented 9 block identicon as per Don Park’s idea but using the srand() setting method of MonsterID
PAuly | 30-Mar-12 at 7:36 pm | Permalink
i want one too
PAuly | 30-Mar-12 at 7:36 pm | Permalink
and again
checkit | 04-Apr-12 at 11:15 am | Permalink
yeah
uli | 04-Apr-12 at 11:24 am | Permalink
guggug
Compu Gator | 15-Apr-12 at 6:06 pm | Permalink
I’d seen these designs on various blogs, but I had never tried to research them. What kind of search terms could one expect to use, anyhow? Generated by assembling shapes into a block based on a hash of de facto user-id. Fascinating. I wonder how one might allow users to select their own color schemes.
Drew | 18-Apr-12 at 8:13 pm | Permalink
Just want to see the generated identicon.
Len | 15-May-12 at 11:17 am | Permalink
A wonderful solution, adding simple uniqueness.
Gonzalo | 24-May-12 at 1:10 pm | Permalink
HELLO !!
adtiya | 26-Aug-12 at 11:20 am | Permalink
hello
testguy | 01-Nov-12 at 5:37 am | Permalink
I of course, am just testing.
Martha | 17-Jan-13 at 6:47 pm | Permalink
I’ve gotten two comments from people on gmail, and the identicon is the same–very different emails BEFORE the @–5 letters vs. 7 letters, only one letter in common. I conclude that the identicon is generated from the part of the email address after the @??
I’d like different identicons for different commenters. But I don’t want to go to IP address because then it will change for commenters with dynamically assigned IPs (= most likely commenters).
Does it really only use the email url (I.e, after the @)? If so, can that be modified? If not, what’s up with my identical results for the gmail commenters?
ScottS-M | 18-Jan-13 at 10:22 am | Permalink
@Martha
That’s strange. Identicons should use the whole email address. If you look at the filename of the identicon (for example with “Copy Image Location” in Firefox), are the two .png image files named the same? If so then you caught a lucky hash collision (or something is going wrong with WordPress passing the full email address). If they’re not the same filename, then there may be some very subtle difference between the two images or you may have gotten lucky in the identicon generation stage (which should also be very very rare).
Martha | 22-Jan-13 at 8:11 pm | Permalink
Well, I do have a single background color and a single foreground color set. But that shouldn’t be so limiting? And I have it set to do 6 squares, not 4.
I have gotten 4 comments from gmail users, (including a test comment from a gmail account of mine and a comment I haven’t approved). They all look identical to me. It is a very simple identicon–stripes around a central square–not much detail to squint at and wonder. The file names do have different strings of numbers.
I have posted test comments from two pairs of email addresses, each pair using the same url (x@z.com, y@z.com, a@c.com, b@c.com). As expected, the pairs sharing the same url are different from each other.
Weirdly, ONE of these seems identical to the gmail identicon–just one. So that makes 5 addresses that have generated what looks like the same image! And at least 3 that generate totally different images.
I’ve scrolled up through your comments here and I don’t see anything similar–or similar in simplicity. See the comments at http://www.halfoftheholylife.org/meditating-at-the-edge/ to view two examples of this image.
Martha | 22-Jan-13 at 10:21 pm | Permalink
Well, now every comment, even pending, that has had a comment approved from that url (after the @) has what appears to be the same identicon–though they have different numbers. Clearly, something is wrong.
ScottS-M | 23-Jan-13 at 11:45 am | Permalink
@Martha
Well those do indeed look pretty identical although they have different file names. That’s very strange. This doesn’t answer the question but if you pull out the colors from those two on your meditating-at-the-edge page, they’re actually subtly different (#f05531 and #ef5a30) which is weird if you’re set to only use a single color.
Just to make sure things are narrowed down:
You didn’t do any editing to the plugin php right?
It looks like your identicons are going through some sort of wordpress.com caching? Did you set something up to do that?
Could you click the “Clear cache” button and see if those particular identicons stay the same?
I’ll email you in case you want me to look at a few of the strange email addresses.
иван | 20-Feb-13 at 6:01 pm | Permalink
Let me see mine.
sharay | 30-Apr-13 at 2:25 am | Permalink
testing…
sharay | 30-Apr-13 at 2:26 am | Permalink
testing . . .
Chiefer | 14-May-13 at 3:51 pm | Permalink
testing.
M | 01-Oct-13 at 3:07 am | Permalink
Hello! LOVE this wonderful plugin! It has been working perfect but I just switched servers and my recent comments are coming in red and white identical identicons that are different than the usual ones. I had tried clearing cache and even tweaking colors but they are not changing. Any ideas what could be the problem? You can see them in this recent post here: http://www.mysticmamma.com/awaiting-the-new-moon-astral-insights-from-sarah-varcas/
Gratitude for your help!
culi | 26-Nov-13 at 7:30 pm | Permalink
Amazing!
dan | 26-Nov-13 at 7:42 pm | Permalink
Any way to generate them through an App?
sefa Güler | 02-Feb-14 at 12:34 pm | Permalink
Any way to generate them through an App?
gummifisch | 10-May-14 at 7:25 am | Permalink
hi there!
we’re using wp_identicon v1.02 since 5 years and got over 1.4k pretty and different identicons. thank you for this nice plugin. but since 2 weeks despite the png-files have different names there will be always the same pattern. this happens to every address even for the old ones where we had temporarily renamed the png files. so we’re a little bit afraid to clear the image cache.
there had been no change neither in the plugin nor the wordpress installation but our hoster switched recently off the php v4. any suggestions?
ps. as i see, it’s exact the same pattern as it is displayed for this post. huh?
gummifisch | 10-May-14 at 7:28 am | Permalink
ps. as i see, it’s exact the same pattern which is displayed for my posts here. huh?
spyrius | 23-Nov-14 at 4:54 pm | Permalink
hmm..my avatar is the same as previous author’s
spyrius | 23-Nov-14 at 4:59 pm | Permalink
ScottS-M | 10-Dec-14 at 9:05 am | Permalink
@spyrius @gummifisch
Thanks for catching that. MySQL made integer overflow an error in their newer versions but I was using that in the randomization code so things stopped getting randomized with new MySQL versions. Should be fixed now.
Rafael Vega | 02-Aug-15 at 12:01 pm | Permalink
Hi, I’ve made a fork of your identicon generator for a personal project and i’d like to release it on github. I don’t see any license or copyright notice on your code so I don’t know if that will be ok or not.
The modifications consist simply in removing all the wordpress stuff and providing a simple command line interface for the identicon generator.
Is it ok to use your code in such a way? is it ok to publish my modifications under an open source license? Which license do you prefer, if any?
Thanks :)
ScottS-M | 03-Aug-15 at 5:51 am | Permalink
@Rafael Vega
Sure that’s fine to split out the identicon stuff. I’ve been meaning to do that myself and haven’t gotten around to it. I guess GPL sounds good unless you had some other preference. Thanks for doing that.
A person | 18-Aug-15 at 10:13 pm | Permalink
Presumably it is possible to calculate the e-mail address which the image was generated for by simply reversing the generation process…
Another person | 18-Aug-15 at 10:14 pm | Permalink
Yes, I thought the same as the above…
Yet another person | 18-Aug-15 at 10:23 pm | Permalink
Me too! This is amazing!
Anonymous Question | 08-Jun-22 at 2:26 pm | Permalink
I made a question mark:?
wanaxe | 14-May-23 at 11:09 am | Permalink
Hello World