WordPress.org

Forums

[resolved] How to set up LOCAL Avatar for admin ONLY on comments Page (10 posts)

  1. Tara
    Volunteer Moderator
    Posted 4 years ago #

    Just to clarify, I would like to set up a local avatar for only ONLY admin (NOBODY ELSE) on comments page of my own blog WITHOUT PLUGIN and Without the third-party avatar services. I want to use my own avatar image.
    I am using Twenty Ten theme.

    Please guide me in simple to follow steps. I searched google and this forum, but did not find anything simple.
    thanks.

  2. Tara
    Volunteer Moderator
    Posted 4 years ago #

    Does no-response means it is impossible to set up a local avatar (without plugins and third-party avatar service) for the Admin Only in WordPress? Its hard to believe!

    If its possible, anybody wants to guide?

  3. alchymyth
    Forum Moderator
    Posted 4 years ago #

    it is not fully clear to me if you
    A. only want to show the admin 'avatar' with the admin comments, and no other avatar images at all?
    or
    B. just have the admin by-passing the gravatar system, and showing a certain image; and all other commenters have the gravatars or default shown?

    to begin with, in functions.php of TwentyTen, there is some comment code, beginning here (about line 290):

    if ( ! function_exists( 'twentyten_comment' ) ) :
    /**
     * Template for comments and pingbacks.
     *

    a few lines down, find:

    <?php echo get_avatar( $comment, 40 ); ?>

    that is probably the point where you can edit the code, to achieve what you want.

    for case B. - something like:

    <?php if( $comment->user_id == 1 ) { echo ''<img alt="" src="'.get_bloginfo('stylesheet_url').'/images/admin-avatar.jpg" class="avatar avatar-40 photo" width="40" height="40">'; }
    else { echo get_avatar( $comment, 40 ); } ?>

    assuming that you have saved an image (40px * 40px) called 'admin-avatar.jpg' in the /images folder of the theme.

    (for case A. just remove the line with 'else' from the suggested code.)

  4. Tara
    Volunteer Moderator
    Posted 4 years ago #

    Thanks alchymyth for your help.

    for this line:
    <?php if( $comment->user_id == 1 ) { echo ''<img alt="" src="'.get_bloginfo('stylesheet_url').'/images/admin-avatar.jpg" class="avatar avatar-40 photo" width="40" height="40">'; }

    I get the following error:

    Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/virtual/XXXX/wp/wp-content/themes/mychildtwentyten/functions.php on line 38

    I greatly appreciate your help.

  5. Tara
    Volunteer Moderator
    Posted 4 years ago #

    resolved.
    I changed: { echo ''<img alt=""

    TO This: { echo '<img alt=""

    I want to thank you again alchymyth

  6. Tara
    Volunteer Moderator
    Posted 4 years ago #

    Hi alchymyth,

    couple of minor questions for you:

    1. What is this? I did not find in Twentyten style.css:
    class="avatar avatar-40 photo"

    2. width="40" height="40" does not change the avatar size?

    Thanks again.

  7. alchymyth
    Forum Moderator
    Posted 4 years ago #

    1.
    these are css classes, which can be used but not need be used to style the avatar image;

    2.
    these are image attributes, that help the browser to build the site:
    http://www.w3schools.com/tags/att_img_height.asp
    (i assume they get overwritten by the css styles)

  8. Tara
    Volunteer Moderator
    Posted 4 years ago #

    thanks alchymyth for your time and help.

    any css suggestion for class="avatar avatar-40 photo"?

  9. alchymyth
    Forum Moderator
    Posted 4 years ago #

    nope - style is personal taste ;-)

  10. Tara
    Volunteer Moderator
    Posted 4 years ago #

    thanks for all the help.

Topic Closed

This topic has been closed to new replies.

About this Topic