Skip to content

Instantly share code, notes, and snippets.

@zachattack
Created February 19, 2014 18:51
Show Gist options
  • Save zachattack/9098911 to your computer and use it in GitHub Desktop.
Save zachattack/9098911 to your computer and use it in GitHub Desktop.
Pesky Facebook sharing scraper fixes. This will allow you total control of the meta info for the Facebook scraper and will allow you to customize the image and title text that is displayed for any node.
// This goes into your template.php file
function YOURTHEME_preprocess_html(&$variables, $hook) {
// Add a title variable to the html template that uses the current node's title.
if ($node = menu_get_object()) {
$variables['html_title'] = $node->title;
}
// Use the theme's logo as the og:image.
$variables['html_logo'] = theme_get_setting('logo');
}
// Put this in the head area of your html.tpl.php
<meta property="og:image" content='<?php print $html_logo; ?>'>
<meta property="og:title" content='<?php print $html_title; ?>'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment