[SOLVED] Facebook don't show thumbnail image when share in the first time

Issue

Tried many ways in this forum but it just work 80% .It mean when i clicked share button , it’s work normally but sometime it still can’t get the thumbnail image when i shared a post

Tried to set og:image in first page but it still not work . Mycode:

<meta property="og:image" content="http://www.example.com/a.jpg">
<meta property="og:image:secure_url" content="http://www.example.com/a.jpg">
<meta property="og:image:width" content="640">
<meta property="og:image:height" content="442">

Is there anyway to fix it? Thanks for reading

Solution

Add this in head section and change your app id and Image width and height should be same as og:image:width and og:image:height

<meta property="fb:app_id" content=" your facebookAppId  " />
<meta property="og:title" content=" This is title of post " />
<meta property="og:url" content="http://www.example.com/a.jpg">
<meta property="og:image" content="http://www.example.com/a.jpg" />
<meta property="og:image:width" content="640" />
<meta property="og:image:height" content="442" />
<meta property="og:description" content=" This is description of post" />

and also this code may help you

<div id="fb-root"></div>
                        <script src="https://connect.facebook.net/en_US/all.js"></script>


     <script>
/********* Code for deleting facebook cache ************/
                                FB.api(
                                        '/',
                                        'POST',
                                        {"scrape": "true", "id": "http://www.example.com/a.jpg"}, 
                                        function (response) {
                                        }
                                );
/********* Code for deleting facebook cache ************/

                            (function (d, s, id) {
                                var js, fjs = d.getElementsByTagName(s)[0];
                                if (d.getElementById(id))
                                    return;
                                js = d.createElement(s);
                                js.id = id;
                                js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.7&appId=xxxxxxxxxxfacebookAppId";
                                fjs.parentNode.insertBefore(js, fjs);
                            }(document, 'script', 'facebook-jssdk'));</script>
                          <div class="fb-share-button" data-href="http://www.example.com/a.jpg" data-layout="button"></div>

Answered By – Shaik Matheen

Answer Checked By – Willingham (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.