Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.1k views
in Q2A Core by
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.

1 Answer

0 votes
by

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.

 

by
edited by
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?
by
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.
...