Community Forums › Forums › Archived Forums › Design Tips and Tricks › Replacing call to gravatar for authorbox with locally hosted image?
- This topic has 5 replies, 2 voices, and was last updated 10 years, 9 months ago by
lvvvvvl.
-
AuthorPosts
-
July 8, 2015 at 4:28 am #158764
lvvvvvl
ParticipantHello,
I noticed in my current child theme the author box calls to gravatar in order to get the author image which significantly reduces load time by a second or two (depending on their servers).
Is it possible to make the author image locally hosted rather than requiring gravatar?
Thank you!
July 8, 2015 at 4:37 pm #158843Tom
ParticipantThis plugin should do what you want:
Choose your next site design from over 350 Genesis themes.
[ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]July 8, 2015 at 7:02 pm #158856lvvvvvl
ParticipantThanks Tom, I stumbled upon that in my searches but I thought perhaps there might be a more elegant solution to increase site performance than adding another plugin.
I imagine that's the advantage of Genesis, its customization. I found this tutorial on how to add social buttons which requires unhooking the author box and creating your own custom version (https://wpbeaches.com/author-box-genesis/) but I don't have the knowledge to figure out how to replace the gravatar call with a locally hosted image that could be linked from one of the author fields.
July 9, 2015 at 12:02 am #158870lvvvvvl
ParticipantI've tried writing up a code that would simply replace the functionality of get_avatar but it's creating some sort of error in my admin panel in which it loads the left side menu but all the content of the admin pages simply displays the blank background.
This is the code which I'm using and pasting the author avatar image url in their 'yim' profile section:
//* Local Author Gravatars *// add_filter('get_avatar', 'get_no_gravatar', 1, 2); function get_no_gravatar( $id_or_email, $size = '180', $default = '', $alt = false ) { // put your new function in here $avatar = '<img alt="'.get_the_author_meta('display_name').' Avatar" src="'.get_the_author_meta('yim').'" class="avatar avatar-{$size} photo avatar-default" height="{$size}" width="{$size}" />'; return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt); };Any ideas what I'm doing wrong?
July 9, 2015 at 1:23 pm #158947Tom
ParticipantBill Erickson has as solution from 2011 that works well. I just tried it in Eleven40 Pro. If your theme uses
genesis_author_box_gravatar_sizeyou can easily make adjustments.http://www.billerickson.net/wordpress-custom-avatar/
Choose your next site design from over 350 Genesis themes.
[ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]July 10, 2015 at 2:21 am #158998lvvvvvl
ParticipantThanks Tom, that worked beautifully and just what I wanted!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.