Modify Gravatar Size in Genesis Framework

Previously, I wrote about how to get your own Gravatar. If you’re a serious blogger and really want your own identity, make sure to read that article.

If you’re a theme developer, there is time when you might need to change the Gravatar image size in your WordPress theme. Even if you’re not a developer, do not worry. This tutorial is very easy to follow. Today, I’ll share some snippets how to change the Gravatar image size in Author Box and Comment Section. This tutorial is specifically dedicated to Genesis Framework users.

1. Change Gravatar Image Size in Author Box

1 2 3 4 5 6 7 8
<?php
// Modify the size of the Gravatar in the author box
add_filter( 'genesis_author_box_gravatar_size', 'afn_author_box_gravatar_size' );
function afn_author_box_gravatar_size($size) {
return '80';
}
view raw functions.php hosted with ❤ by GitHub

Make sure to change the number 80 to any size as you wish. Put the code above in your theme functions.php file. If you’re using a child theme, make sure to put the code in your child theme’s
functions.php file. Personally, I recommend to put the code in your functionality plugin. I’ll write more about that later.

2. Change Gravatar Image Size in Comment Section

While the previous code can only change the Gravatar size in Author Box, the code below can be used to modify the Gravatar size in comment section.

1 2 3 4 5 6 7 8
<?php
// Change Gravatar Image Size in Comment Section
function afn_comment_list_args( $args ) {
return array( 'type' => 'comment', 'avatar_size' => 80, 'callback' => 'genesis_comment_callback' );
}
add_filter( 'genesis_comment_list_args', 'afn_comment_list_args' );
view raw functions.php hosted with ❤ by GitHub

That’s it. I hope the tutorial will be useful.

Comments

  1. Denrrou says

    Hi!

    Is there any way to set the nested comments to an smaller size?

    What i would like to do is to make the first level comments show a gravatar size of 100px and the replies be 60px.

    Is that possible?

    Thanks a lot!

    • Editor says

      Hi,

      I’m not really sure how, but I think it’s possible via CSS. For example, we filter the size gravatar image of the first level comment using the snippet above. Then for the second and third level comments (or child comments), we can specify the width and height to be 80% and auto, respectively.

      I believe you can find the class/id of the child comments from the WordPress Codex
      or by simply search for it in Google.

Leave a Reply

Your email address will not be published. Required fields are marked *