Search code examples
javascriptjqueryhtmlfacebook-opengraph

Dynamically changing the content of: meta property="og:image"


I want to change the main photo in a web page, I just have the url page. So I decided to use the meta written for Facebook sharing.

I want to change the image in: meta property="og:image" content="http://myweb.com/image.jpg"


Solution

  • Change it with jQuery like:

    $('meta[property=og\\:image]').attr('content', 'http://myweb.com/image.jpg');