On my website I am trying to create a Facebook thumbnail so that when I share a picture I want Facebook to select a specific picture. I have ONE number in each url of my site and according to that number I have an image that should display in that page. Any way I wrote the code below, but for a reason it is not working. I want to keep href empty then access it through document.getElementById('ShareImageID').href and change its value according the value of the var ShareImageIdVar. Any ideas how can I get this to work ?
<link rel="image_src" href="" id="ShareImageID"/>
<script>
var ShareImageIdVar = location.href.match(/\d+/);
document.getElementById('ShareImageID').href = "http://www.mysite.com/Images/"+ ShareImageIdVar +".jpg";
</script>
To get Facebook to select a photo, you need to specify the
og:imagemeta tag in theheadsection. See http://ogp.me for info on how to set those up properly. Once you got those setup correctly, then lint the url at https://developers.facebook.com/tools/lint