I am using the following code but it is not working ? can I even dinamically do that ? if yes how ? I was using og:image meta tag but they did not work because browsers do not read javascript. any help ?
<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>
the Idea is that facebook always will look for
<link rel="image_src" href="" id="ShareImageID"/>
and use the Image link inside the href and display it first, but if it did not find it it will choose a random image.
The og:image is cached by facebook for every URL. It does not update dynamically. You have to create a custom url for every image i.e. using a GET parameter and change the image URL in the og:image tag on the server side.
But keep in mind that likes then go to that URL as well.