Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Supports OpenGraphProtocol
- */
- function ttcn_opengraph(&$vars) {
- if (arg(0) == 'node') {
- $node = menu_get_object();
- if ($node->field_thumbnail[0]['value']) {
- $image = $node->field_thumbnail[0]['value'];
- }
- elseif (!empty($node->field_thumbnail_image[0]['filepath'])) {
- $image = '/' . $node->field_thumbnail_image[0]['filepath'];
- }
- elseif (!empty($node->field_product_image[0]['filepath'])) {
- $image = '/' . $node->field_product_image[0]['filepath'];
- }
- }
- elseif (arg(0) == 'user') {
- $user = menu_get_object('user_uid_optional');
- if ($user->picture) {
- $image = '/' . $user->picture;
- }
- }
- if (empty($image)) {
- $image = '/sites/default/files/misc/icon.png';
- }
- if ($title = drupal_get_title()) {
- $vars['head'] .= '<meta property="og:title" content="' . str_replace('"', '"', strip_tags($title)) .'" />' . "\n";
- }
- if (strpos($image, '://') === FALSE) {
- $image = 'http://vtcdn.com' . str_replace('/files/', '/files/imagecache/s180/', $image);
- }
- $vars['head'] .= '<meta property="og:image" content="' . $image . '" />' . "\n";
- if (request_uri() == '/') {
- $type = 'website';
- }
- elseif (arg(0) == 'blogs') {
- $type = 'blog';
- }
- else {
- $type = 'article';
- }
- $vars['head'] .= '<meta property="og:type" content="' . $type . '" />' . "\n";
- $vars['head'] .= '<meta property="og:url" content="' . token_replace('[metatags-url-alias]') . '" />' . "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement