talkinggoat
Member
I need to add a meta og:image property for facebook into the head of a page. Is it even possible to add elements to the head of a document from a Fabrik element or what is the best way? I can write it in Javascript, but it does no good, because Facebook scrapes the page before the JS has run.
Currently, I am adding the image into a textarea element and assigning it an ID tag of fb_image, to make things a little more dynamic.
Adding the meta in JS
Currently, I am adding the image into a textarea element and assigning it an ID tag of fb_image, to make things a little more dynamic.
Adding the meta in JS
JavaScript:
var fbImage = document.getElementById('fb_image').src;
var createMeta = document.createElement('meta');
createMeta.setAttribute('property','og:image');
createMeta.content = fbImage;
document.getElementsByTagName('head')[0].appendChild(createMeta);