• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
Callia Web logo

Callia Web

Websites - Design with Purpose

  • Digital toolkits
    • Venture toolkit
    • Go-pro toolkit
    • Intrepid toolkit
  • Services
    • Digital toolkits
    • Design services
    • Simple websites
    • Support and care plans
    • Website consultation
  • Our Work
  • Processes
    • Accessibility matters
    • Branding Process
    • Toolkit and website process
  • About
  • Let’s Talk

Disable comment avatars in Genesis

30 Mar 2018 | WordPress

A client of ours wanted to disable the comment avatars on her blog and initially we thought that simply taking the tick out of setting “Avatar Display” would do it. However that disabled all avatars including the avatars in the author box and the Genesis user profile widget, not what we wanted.

Avatar display settings

So we had a rummage in the Genesis Framework code and in genesis/lib/structure/comments.php there is a filter called genesis_comment_list_args which in turn calls wp_list_comments.

In the codex for wp_list_comments it states that:

avatar_size ( integer ) Size that the avatar should be shown as, in pixels. http://gravatar.com/ supports sizes between 1 and 512. Use 0 to hide avatars.

So it looked like it would be simple to add a filter using genesis_comment_list_args to give an avatar_size of 0. However, this returned an avatar of 96px!

Turns out this is because in the function used to output the comments in Genesis there isn’t a check for $args['avatar_size'] being equal to 0 before calling get_avatar, and get_avatar checks for a value less than 1 and applies a default value of 96px. The default WordPress function for outputting the comments does this check.

So our first choice is to use the same filter to stop the use of the Genesis comment function by supplying a blank string to the callback arg.

You can view the code below on github too.

add_filter( 'genesis_comment_list_args', 'jmw_disable_genesis_comment_avatar' );
/**
 * Disable comment avatars in Genesis.
 * Set comment avatar size to 0 and use the default WordPress comment function instead of the Genesis one.
 *
 * @param array $args Comment args
 * @return array Filtered comment args
 */
function jmw_disable_genesis_comment_avatar( $args ) {
	$args['avatar_size'] = 0;
	$args['callback'] ='';
	return $args;
}

This has the downside of losing all the Genesis hooks in genesis_html5_comment_callback and the format is a little different.

If this matters to you then you have a second choice. This is to copy the genesis_html5_comment_callback function and create your own custom comment function with a check to ensure $args['avatar_size'] is not equal to 0 before the get_avatar function. Then call this function using the genesis_comment_list_args filter.

An issue has been submitted to the Genesis github repo (if you have access) to add this check to the Genesis comment functions. If/when this fix is added then you can remove the $args['callback'] =''; line and use the Genesis function.

Featured Image: Photo by Toshi on Unsplash

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on E-mailShare on WhatsApp

About Jo Waltham

Jo Waltham is the founder of Callia Web and is passionate about helping small business owners and bloggers with their websites and online marketing. Connect with Jo and the rest of the Callia Web team on Twitter or Facebook. Alternatively send us a message.

Liked this post? Subscribe to get our next post direct to your inbox.

  • Please enter your email address if you would like us to contact you by email with information about our services which we feel may be of interest to you. We will process your data in accordance with our privacy notice. You may withdraw this consent at any time by clicking the unsubscribe link in any message we send, or by emailing hello@calliaweb.co.uk.
Previous Post: « padlock and chain 7 website mistakes that make potential customers think you’ve gone out of business
Next Post: How to spring clean your blog How to Spring Clean your blog on Callia Web - Image nik macmillan unsplash »

Reader Interactions

Comments

  1. Mike Hemberger

    30 Mar 2018

    Hey Jo! I’ve had to do this before as well, and did it directly with the get_avatar() filter. See here:

    // Remove avatars.
    add_action( 'genesis_list_comments', function() {
        add_filter( 'get_avatar', 'prefix_remove_avatars' );
    }, 0 );
    
    // Add them back, by removing the filter that removes them.
    add_action( 'genesis_list_comments', function() {
        remove_filter( 'get_avatar', 'prefix_remove_avatars' );
    }, 999 );
    
    // Return empty string.
    function prefix_remove_avatars() {
        return '';
    }
    Reply
    • Jo Waltham

      30 Mar 2018

      Thanks Mike. I like your solution because you can still use the Genesis comment function.

      Reply
    • Urvashee

      26 Mar 2019

      Looking for exactly this. Thanks so much for sharing!

      Reply
  2. AJ

    4 Jan 2020

    I was struggling to find a solution to this problem as well. Although the following linked page doesn’t appear to be specific to Studiopress themes, the simple code provided worked perfectly for me for removing the comment avatars while retaining the author box functionality: https://www.billerickson.net/remove-avatars-from-comments/

    Reply
  3. Jo Waltham

    4 Feb 2020

    Thanks for the link AJ. Bill always has very neat solutions.

    Reply

Leave a Reply Cancel reply

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

Ready to take your project to the next step?

Give us a call, we’re here to discuss what your project needs.

Let’s get started

Contact us

Telephone: 01672 666001 / 666002

Email: hello@calliaweb.co.uk

  • Facebook
  • Twitter
  • Instagram

Quick links

Digital toolkits

Services

Our work

Testimonials

Blog

Popular posts

Using headings in WordPress

Accessibility basics

Image sizes and aspect ratios

Making images equal size

Beginner’s guide to Analytics

Legal

Privacy policy

Terms of service

Company number: 08316519

VAT number: GB204336250

Registered address: Bowman House, Royal Wootton Bassett, Wiltshire, SN4 7DB

Copyright © 2022 · Callia Web Ltd · All Rights Reserved