Reputation: 51
I have images saved in storage and I want to share them on Facebook. Sharing is working but not the way I tought it would. I will post examples below to show what I get and what I want.
So I get black post that needs to be clicked on to see image, like this:
And I want it to be like this:
HTML:
<button onclick="fb()">Facebook</button>
<img src="storage/images/lang/myImage.png" id="imgfb" style="display:none"/>
JavaScript:
<script>
function fb(){
var imgsrc=document.getElementById("imgfb").src;
var fbpopup = window.open("https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(imgsrc), "pop", "width=600, height=400, scrollbars=no");
return false;
}
</script>
Upvotes: 2
Views: 2206
Reputation: 41
You need to set organic tag for image on that link.
On head section of html
<meta property="og:image" content="{{asset('YOUR-IMAGE-LOCATION')}}" />
The are also other meta tags available for title and description, do check them on https://developers.facebook.com/docs/sharing/webmasters/
Upvotes: 3