I working on CMS, which I can't manage to mess around with default meta values
I've added addthis share buttons. then I've used jquery to change meta values as following
$(document).ready(function(e) {
$('meta[property="og:title"]').remove();
$('head').append('<meta property="og:title" content="<?=$title?>">');
$('meta[property="og:image"]').remove();
$('head').append('<meta property="og:image" content="<?=$image?>">');
});
when clicking on facebook share button, title is changed as needed but image is not changed.
how can I make it work on image value
Since the page loads just once, I can assign the OG:IMAGE URL once... But I really would like to have each picture with its own OG:IMAGE, since this is a photo album.
Changing OG meta tags client-side is of no actual use – because Facebook will read those tags through it’s scraper, which means they will do an HTTP request for your URL and see what’s in the HTML code; and the scraper does not execute any JavaScript.
Solution: Provide an individual URL for each photo with its own meta information – and have your like button/share functionality/whatever FB feature point to that URL for each photo.
(How you handle things client-side does not matter – you can still display all the photos in one page, load new content via AJAX, whatever you like – but you will need separate URLs for your photos for them to be recognized as individual Open Graph objects.)