What makes you happy ?

"Karma man, just remember Karma. Treat things nice and nice things happen to you." © Claire

Random Gravatars

13:30 Saturday 20 Oct 07

To create random gravatars for your comments so you have neither the default, empty spaces or the same one of your choice.

First get Matt’s script. I first used this when I wrote a couple of years ago how to get random headers on the blog and it’s come in handy again. Save that as it is.
Next go find your images and place them in a folder.
Put the script inside that folder.
Upload and link from your comments.php
Easy.

Here’s one I made earlier.
Download this folder, unzip.
It contains all the images I’m using here right now (127 of them) and the script
Upload to your site
Open comments.php and change the gravatar code to
<img src="< ?php gravatar("", 80 , "http://your-domain/your-folder/ctar.php"); ?/>
After saving the changes your comments should now have the same images that I am using. Once you see it working all you need to do is change the images in that folder.
If you want a long example, click the link in the top right to the “What makes you happy” post.

If you want to batch resize, I recommend ImageBadger on Windows.
If you want to batch rename – again on Windows – 1-4a Rename is excellent.

And should you want to keep the images in the download for some reason, not a problem.
Of course you don’t need to use all 127. Delete all but a couple. It’s there for testing. (It’s an 850kb folder to upload so deleting a few will speed things up).

An improvement would be to check for an author url and link the gravatar to that and if there is no author url to then link to a default of the blog owner’s choice.. The latter is easy – wrap the code above in a href – but the ‘if’ bit throws me. Plugin territory probably.

More: WordPress
  1. Matt
    1
    • That’s pretty cool!

    20:22 Saturday 20 Oct 07


  2. Cyndy
    2
    • As Matt said, that is pretty cool!

      Also, hi…it’s only been forever since I poked around here. I suck like that. :)

    08:48 Monday 22 Oct 07


θ α λ κ

Think. Then type.

*     *    

Comment RSS / Trackback




|| Home ||

FreshlyPressed - Feed - Privacy - 3.1.3 - 3,203 - 10,494 - 0.193