My site uses a custom content type that is essentially an article. Each page offers a Facebook share link, and I created and configured a new meta tag default for this content type.

Anonymous users can share nodes of this content type and everything works perfectly when displayed on facebook; the appropriate title, image and summary appear along with the link. Anonymous users share an http url.

Authenticated users can share the exact same node, except it's accessed via an https secure url. When authenticated users share this on facebook, it is displayed with the global website image and description.

I understand this is a facebook issue, but functionally I am not achieving my desired outcome. Is there a token I can enter into the og url field that will output the non-secure url? Or is there some other way to allow authenticated users to share the non-https address? I would be very grateful for any guidance.

CommentFileSizeAuthor
#9 1412238-add_secure_url.patch1.14 KBaidanlis

Comments

grasmash’s picture

You can just use the theme_metatag_opengraph() function in your template.php file to process the tag before it is output:

/**
 * Theme callback for an OpenGraph meta tag.
 */
function THEMENAME_metatag_opengraph($variables) {
  $element = &$variables['element'];
  switch ($element['#name']) {
    case 'og:image':
      $element['#value'] = str_replace('https://', 'http://', $element['#value']); 
      break;
  }

  element_set_attributes($element, array('#name' => 'property', '#value' => 'content'));
  unset($element['#value']);
  return theme('html_tag', $variables);
}
damienmckenna’s picture

Status: Active » Fixed

@madhatter23: thanks for providing a solution.

This is such an edge case I don't think it needs further documenting.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

aidanlis’s picture

Status: Closed (fixed) » Active

What about supporting og:image:secure_url?

https://developers.facebook.com/bugs/405588419493203

damienmckenna’s picture

Version: 7.x-1.0-alpha4 » 7.x-1.x-dev

@aidanlis: That's the opposite of what he's trying to do, but good tip anyway.

aidanlis’s picture

Version: 7.x-1.x-dev » 7.x-1.0-alpha4

This was my quick hack to strip out the https and preprocess the image:

function THEMENAME_html_head_alter(&$head_elements){
  if (isset($head_elements['metatag_og:image']['#value'])) {
    $img = &$head_elements['metatag_og:image']['#value'];
    $img = str_replace('https://www.', 'http://static.', $img);
    $img = str_replace('/sites/default/files', '/sites/default/files/styles/ogthumb/public', $img);
  }   
}
damienmckenna’s picture

Status: Active » Fixed

You could also use hook_tokens_alter.

damienmckenna’s picture

Status: Fixed » Closed (fixed)
aidanlis’s picture

Title: og url - is there a token to strip the ssl designation or some other workaround? » Support og:image:secure_url
Version: 7.x-1.0-alpha4 » 7.x-1.x-dev
Status: Closed (fixed) » Needs review
StatusFileSize
new1.14 KB

Hijacking this issue, sort of, as this is the issue that shows up in google searches.

We need to support og:image:secure_url, via http://ogp.me/#structured

Status: Needs review » Needs work

The last submitted patch, 1412238-add_secure_url.patch, failed testing.

damienmckenna’s picture

Title: Support og:image:secure_url » og url - is there a token to strip the ssl designation or some other workaround?
Status: Needs work » Closed (fixed)

Please open a new issue for this new tag.