WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Customize get_avatar css class (5 posts)

  1. qzplx
    Member
    Posted 3 years ago #

    Hi All,

    I need to modify the default class for get_avatar template tag how is this possible ?

    Based codex the default class for gravatar is:
    <img alt='' src='http://gravatarurl_or_default'
    class='avatar avatar-$size' height='$size' width='$size' />

    I need to change it to:
    class= author_gravatar alignright_icon

    Is there any possibility doing this ?

    Thanks,
    Raff

  2. qzplx
    Member
    Posted 3 years ago #

    Bump.. In case anyone has experience like this...

  3. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    get_avatar() uses a filter 'get_avatar' at the end, which you could use to change your css classes;

    http://codex.wordpress.org/Plugin_API/Filter_Reference

    add_filter('get_avatar','change_avatar_css');
    
    function change_avatar_css($class) {
    $class = str_replace("class='avatar", "class='author_gravatar alignright_icon ", $class) ;
    return $class;
    }
  4. qzplx
    Member
    Posted 3 years ago #

    Hi alchymyth,

    I put this on function.php and its works as simple is that based on Twentyten Template.
    I hope it will help the others.

    Thanks a lot for your helps

    Cheers,
    Raff

  5. Ben Cao
    Member
    Posted 3 years ago #

    I used this function,It works! Think you

Topic Closed

This topic has been closed to new replies.

About this Topic