• Resolved ScottAgirs

    (@scottagirs)


    Damien, awesome work! As soon as my project picks up, you’re project is on top of the list to appreciate! ??

    One thing I need help with, though, which looks like a bug, is get_avatar_url, which returns gravatar image instead of Facebook.

    Here is the buggy cody:

    
     $author_avatar  = get_avatar_url( $author_id );
    
     <img alt="" src="'.$author_avatar.'" class="img-circle avatar avatar-55 " height="55" width="55" style="height:55px;width:55px">

    However, the echo get_avatar(get_the_author_meta( 'id' )), works fine and returns the right Facebook profile.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Damian

    (@timersys)

    Hi @scottagirs,
    yes the plugin only filters get_avatar and not get_avatar_url but you can easily get it like this:

    
    
    			// get avatar with facebook id
    			if ( $fb_id = get_user_meta( $author_id, '_fb_user_id', true ) ) {
    
    				$fb_url = 'https://graph.facebook.com/' . $fb_id . '/picture?width=' . $size . '&height=' . $size;
    				
    
    			}
    Thread Starter ScottAgirs

    (@scottagirs)

    Hey @damian,

    Thanks for your reply, that’s awesome!!
    Just trying to figure out how to use it, haha – a true newbie here..

    function single_post_entry() {
      global $post;
    		// get avatar with facebook id
    		$fb_id = get_user_meta( $author_id, '_fb_user_id', true );
    		$fb_url = 'https://graph.facebook.com/' . $fb_id . '/picture?width=' . $size . '&height=' . $size;
    	$author_id      = $post->post_author;
    	..
    	$author_avatar  = $fb_url;
    	..
    
          echo '<div class="..">
    	<div class="..">
    		<img alt="" src="'. $author_avatar.'" class="..">
    	</div>
    ..

    I tried to put the code you provided into a function and assign the function to a variable $author_avatar, but that didn’t work.

    Would you be able to help solving this?

    EDIT:

    with this setup:

    function single_post_entry() {
      global $post;
    		// get avatar with facebook id
    // get avatar with facebook id
    	if ( $fb_id = get_user_meta( $author_id, '_fb_user_id', true ) ) {
    
    		$fb_url = 'https://graph.facebook.com/' . $fb_id . '/picture?width=' . $size . '&height=' . $size;
    
    	}
    	$author_id      = $post->post_author;
    	..
    	$author_avatar  = $fb_url;
    	..
    
          echo '<div class="..">
    	<div class="..">
    		<img alt="" src="'. $author_avatar.'" class="..">
    	</div>
    ..

    the src=”$value” of the img element on front-end is (unknown)

    • This reply was modified 6 years, 10 months ago by ScottAgirs.
    • This reply was modified 6 years, 10 months ago by ScottAgirs.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_avatar_url returns the gravatar, instead of FB pic’ is closed to new replies.