Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
  • Register
Welcome to the Q&A for Question2Answer.

If you have questions about the platform, click here to ask and please use English.

If you just want to try Q2A, please use the demo, which also grants admin access.

Apr 29: Q2A 1.5.2

How to show avatar image of the questioner in Facebook?

+1 vote
When someone click one Facebook LIKE button then on his facebook wall that question posted with 'Share this question via Email' Thumbnail. Is it possible to show a particular thumbnail (avatar image of the questioner) if question have no other picture?

Thank you.
asked Nov 12, 2011 in Q2A Core by Raj

1 Answer

0 votes

Good question :) Here's how I did it:

        function head_custom() {
            if (qa_opt('buddypress_integration_enable') && qa_opt('buddypress_integration_avatars'))
                $avatar = preg_replace('|.*src="([^"]+)".*|i','$1',bp_core_fetch_avatar( array( 'item_id' => $this->content['q_view']['raw']['userid'], 'width' => qa_opt('buddypress_integration_avatar_w'), 'height' => qa_opt('buddypress_integration_avatar_h'), 'email' => $email ) ));
            else if(isset($this->content['q_view']['avatar']))
                $avatar = preg_replace('|.*SRC="([^"]+)".*|i','$1',$this->content['q_view']['avatar']);
            if(isset($avatar))
                $this->output('<link rel="image_src" href="'.$avatar.'" />');
            qa_html_theme_base::head_custom();
        }

 

This puts a link in your page's header to the image, with rel="image_src", which facebook should pick up.  It should work for non-wp integration and buddypress integration (via buddypress plugin).  For ordinary wp-integration, you'll have to figure out how to get the avatar url yourself.

 

answered Nov 12, 2011 by NoahY
Thank you for quick answer.

I put this code in qa-theme-base.php by replacing
        function head_custom()
        {} // abstract method

But getting internal server error.  I am not using wordpress/buddypress. Am I doing something wrong?
This code doesn't belong in qa-theme-base.php, it belongs in a custom layer, or in a theme's qa-theme.php file.  If for some reason you need to put it in qa-theme-base.php, remove the last line of the function, and it should work, but that's really a bad idea.