September 26, 2008 ~ Blogger Tutorials

In blogs where there is more than one author, some distinction often becomes necessary. A good way of achieving this is by displaying each author’s personal image right next to his or her post title.

This is what I will explain in this post. Though this effect can be done with JavaScript (as explained -in Spanish- in El Escaparate), it can also be done just by adding Blogger conditional tags.

Installation

From our Template Editor (Layout, Edit HTML) in our Blogger Dashboards, we must look for the following code:

<b:includable id='post' var='post'>
<div class='post hentry uncustomized-post-template'>
 <a expr:name='data:post.id'/>

And immediately after the line in red, add the following lines:

<b:if cond='data:post.author == "Author1_Username"'>

<span class="author"><img src="Image1_URL"/></span>
</b:if>

<b:if cond='data:post.author == "Author2_Username"'>
<span class="author"><img src="Image2_URL"/></span>

</b:if>

(You can repeat this code and keep modifying it, in case your blog has more than two blog authors.)

This code is case sensitive. So, Fernando is not the same as fernando or FERNANDO. The username we have to insert in the code above must match exactly the one displayed in our Blogger Profile. Also, the ideal image size is around the 30×30 – 50×50 pixels.

Customization

In order to style the image, we need to copy and customize the following code, right before ]]</b:skin>:

.author img {
padding: 0;
float: left;
border: none;     /*We may add some border to the images.*/
margin: 0 10px 10px 0;
}

The float property, as well as the margin, might change according to where we want the images to be displayed.

Demo

You can take a look at the result right here.

More in this category:

  • Thanks so much.
  • You're welcome!
  • I have been searching for this code for months, literally. Thank you so much! Oh, and FYI, it also works if you want to add pics to a footer... I just relocated the code to the footer portion after this bit of code:

    Thanks a million!!!

    I wish I could figure out how to wrap the footer text around the picture, but I'm sure playing around I'll be able to figure it out.
  • You're welcome, I Heart Monster. I'm glad this worked for you! (: And yeah, it also works in the footer. You can even insert the code in the post body area and it will work just fine. Again, I'm glad it worked!

    Regards,
  • Dany Soares
    Nice tutorial. Congratulations. It's exactly what I need.
  • I'm glad it worked for you!
blog comments powered by Disqus