Author Profile Picture Missing
-
Thank you so much for this Plugin!
Unfortunately there seems to be an issue with it: The Author Profile Picture is now missing! There is only the “place holder” showed instead. The checkbox in my profile is activated. My Gravatar Picture is shown next to my comments, but not next to my Author Profile.Thanks for your help!
The page I need help with: [log in to see the link]
-
Can tell me more about your Avatar settings? I’ll try to recreate the situation. Here’s what I’ve gathered so far:
- You have enabled gravatars for your user.
- You’ve got a gravatar image associated with your email address.
- This image is showing with your comments.
- The image is not showing the “Your Profile” screen.
Ah, I’ve looked at the site and I think I know what you meant: You were talking about the “Über den Autor” box at the end of your posts? Are you using another plugin for that? Because the HTML looks a bit weird:
<img src="https://[domain]/wp-content/uploads/2018/04/[hash].png" alt="" /> <img alt="" src="https://[domain]/wp-content/plugins/avatar-privacy/public/images/comment-bubble.svg" height="100" width="100" />There’s two separate image tags embedded there.
No, I dont use a Plugin for this.
<img src="https://[domain]/wp-content/uploads/2018/04/[hash].png" alt="" />This is the image I uploaded for the “WP User Avatar” Plugin. Pretty strange that this line is still there, because I deactivated (but not uninstalled) it.
I thought it might be a hashing issue, but since you’ve changed the default icon to “Blank” and the second
<img/>is still there, I would assume that it’s somehow hardcoded in the template? Could you post a snippet of the relevant template file?you´re absolutely right – I found this in single.php:
style="display:none;" src="http://www.retropixels.at/wp-content/uploads/2018/04/xxxxxxx.png" alt="" />';?>It seems that the plugin WP User Avatar has modified the single.php this way ?!
So I Uploaded the original PHP File, which replaced theabove code with
echo '<img itemprop="image" style="display:none;" src="http://gravatar.com/avatar/' . $hash .'" alt="" />';BUT: Still no Author-Picture 🙁
I’m not sure what you intend to do with an
<img>withstyle="display:none;"? Could you please include a snippet with the complete author box template? There should be a call toecho get_avatar(...);for the image and nothing else. I need to se the exact parameters to thatget_avatarcall, though.Well, thats a good question. Cant answer that, because I´m not the Author of the Theme but it seems pretty senseless 😉
Here is the complete code of the author-box :
<!-- about the author --> <div id="author-block" class="box-shadow-2px clearfix" itemscope="" itemtype="http://schema.org/Person"> <h2 class="author-title"><?php _e('About the author', 'color-theme-framework'); ?></h2> <div id="author-avatar"> <?php $user_email = get_the_author_meta( 'user_email' ); $hash = md5( strtolower( trim ( $user_email ) ) ); echo '<img itemprop="image" style="display:none;" src="http://gravatar.com/avatar/' . $hash .'" alt="" />'; ?> <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentyeleven_author_bio_avatar_size', 100 ) ); ?> </div><!-- #author-avatar --> <div id="author-description" class="padding-20"> <meta itemprop="additionalName" content="<?php the_author_meta( 'first_name' ); ?> <?php the_author_meta( 'last_name' ); ?>"> <meta itemprop="url" content="<?php the_author_meta( 'user_url' ); ?>"> <p><?php the_author_meta( 'description' ); ?></p> <?php ct_get_author_social(); ?> <a style="font-size: 11px;" href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"><?php _e('View all articles by ', 'color-theme-framework'); the_author_meta('display_name'); ?></a> </div><!-- #author-description --> </div><!-- #author-info -->You need to replace
get_the_author_meta( 'user_email' )withget_the_author_meta( 'ID' ), otherwiseget_avatar()does not know you are looking for a user instead of an anonymous commenter.As for the hardcoded
<img>, it’s probably there to provide theimagemeta data element forschema.orgmarkup. However, it’s unnecessary. You can pass additional HTML attributes to theget_avatar()function directly. Please replace the “author-avatar” part (everything within the<div>) with this:<?php echo get_avatar( get_the_author_meta( 'ID' ), apply_filters( 'twentyeleven_author_bio_avatar_size', 100 ), '', '', [ 'extra_attr' => 'itemprop="image"' ] ); ?>It works now perfectly! Thanks!
I’m curious. Why does
get_the_author_meta( 'user_email' );not work?get_avatar can be used with ID *or* email, but I can confirm it is just working with ID.
See also: https://codex.ww.wp.xz.cn/Function_Reference/get_avatarCan you explain this further @pputzer? Thanks in advance!
All the best,
TorstenThe problem is that Avatar Privacy needs to differentiate between anonymous comment authors and registered WordPress users to properly check for opt-in (and also to prevent fraudulent uses of the avatar image). Opt-in for users is stored in
user_meta, opt-in for anonymous commenters in a separate table.Since Avatar Privacy 1.1, registered users can allow anonymous commenters to use their avatars (i.e. to allow logged-out commenting) via a checkbox in their profile pages.
@zodiac1978: You can find the logic in the
parse_id_or_emailmethod of theAvatar_Handlingclass.
The topic ‘Author Profile Picture Missing’ is closed to new replies.