I have a node which has multiple images attached to it. And each image should also be printed in a <meta property="og:image" content="image_url" />
metatag. I have tried to use drupal_add_html_head()
for each image in a template_preprocess_page()
, but only the last image is printed as metatag.
function mytheme_preprocess_page(&$variables) {
...
// add multiple og:image tags
foreach ($images as $image) {
$element = array(
'#tag' => 'meta',
'#attributes' => array(
"property" => "og:image",
"content" => $image,
),
);
drupal_add_html_head($element,'facebook_share_image');
}
}