Friday, 10 September 2010

Comment avatar for people who don't have one ?

Some peoples ask me how to add an image for people who don't enable their avatar in comments . Yes, I missed this function when making template . In my templates, you see nothing in avatar frame if people who comment don't enable their avatar . Why don't we add an image in avatar frame for them instead of using blank ?  Like this





or like this (^^make it look like Gravatar)


the trick here is very simple .
Just find this code :
<b:if cond='data:blog.enabledCommentProfileImages'>
<data:comment.authorAvatarImage/>
</b:if>


and replace it with

<b:if cond='data:blog.enabledCommentProfileImages'>
<data:comment.authorAvatarImage/>
<b:else/>
<img src="http://img844.imageshack.us/img844/3447/unknownuser.jpg"/>
</b:if>

with this code ,if people don't enable their profile images (or their Blogger avatar in comment ) it will show image <img src="http://img844.imageshack.us/img844/3447/unknownuser.jpg"/>
you can replace image which I marked in bold to your own

9 comments:

  1. muchas gracias men, eres un experto..

    ReplyDelete
  2. Nice trick... i will surely apply it on my blog soon...
    thank you...

    ReplyDelete
  3. Hey,

    I cannot find the code in my template (Simplex Newspaper II) that needs to be changed. What about the templates that don't have this code:

    ReplyDelete
  4. Amanda, to find the code you first need to "expand widgets". Then you can do that

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Thanks Micho, I expanded the widget, found the code, and made the changes. Unfortunately, it did not work for me and the images are still blank. Thanks though.

    ReplyDelete
  7. I found out a very easy way to implement default avatar, just look for:

    .vcard img { /* Avatar style between comments */
    border:1px solid #d5d5d5;
    padding:1px;
    background:#fff;
    position:absolute;
    position:absolute;
    top:7px;
    right:5px;
    width:30px;
    height:30px;}

    And, in the background, just add an avatar image, like this:

    .vcard img { /* Avatar style between comments */
    border:1px solid #d5d5d5;
    padding:1px;
    background:#fff url(http://2.bp.blogspot.com/_K85Ifm8hXcw/TS2wy2fD8SI/AAAAAAAAGoc/IjlFn3zaGo8/s1600/desconhecido.jpg) no-repeat center center;
    position:absolute;
    position:absolute;
    top:7px;
    right:5px;
    width:30px;
    height:30px;}

    It works fine, just take a look:

    http://www.evaldolima.com.br/2011/01/nunca-antes-na-historia-deste-pais-voce.html

    ReplyDelete
  8. still i couldn't fix the blank image.... :( any idea

    ReplyDelete