javascript - facebook share not adding image -
i have facebook tabs app. , inside there have share button
<p class="share-btn" id="button">share this</p> <script> (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"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <script> window.fbasyncinit = function () { fb.init({ appid: 'app id', cookie: true, xfbml: true, version: 'v2.8' }); window.facebookshare = function (callback) { var id = @model.id; var options = ({ method: 'share', href: 'https://www.facebook.com/my app url here&app_data=' + id }), status = ''; fb.ui(options, function (response) { console.log(response); if (response && !response.error_code) { status = 'success'; $.event.trigger('fb-share.success'); } else { status = 'error'; $.event.trigger('fb-share.error'); } if (callback && typeof callback === "function") { callback.call(this, status); } else { return response; } }); } }; $('#button').on('click', function (e) { e.preventdefault(); facebookshare(function (response) { // simple function callback //console.log(response); }); }); // custom jquery events $(document) .on('fb-share.success', function (e) { window.location.href = "/quiz/finished"; }) .on('fb-share.error', function (e) { //alert("fail"); }); </script> this shares link ok not adding thumbnail. share looks this:
but in layout have these:
<meta property="og:url" content="http://www.your-domain.com/your-page.html" /> <meta property="og:type" content="website" /> <meta property="og:title" content="your website title" /> <meta property="og:description" content="your description" /> <meta property="og:image" content="https://www.codeproject.com/kb/aspnet/aspnetpaths/selectimage.png" /> how can that? , there chance pass image using options?

Comments
Post a Comment