Looking in the module's code, it looks like you had the same thought. +1 for having this implemented.

One thought on how to do it from a UI standpoint would be to add a dropdown to the content type edit pages if that type has been selected to show a like box, and it has any imagefields.

Comments

gagarine’s picture

I think the drop down need to be in the settings not on each node edit (my user know any things about FB social plugins ;)).

I thinking a easy implementation.

for all
og:title
og:site_name
og:type
og:image
og:description

Provide a field but with http://drupal.org/project/token

beauz’s picture

+1 for this feature

ferdi’s picture

I think the cleanest way to do that is to have a separate module which fully implements the opengraphprotocol (http://opengraphprotocol.org/). I was hoping to hear from http://drupal.org/project/open_graph.

axel_exa’s picture

Could anyone give me some advise on how to change the og metadata now (as long as there's no working module for it)? i would like to change og:title so that it submits the content of a certain cck field. thanks

egomac’s picture

My thoughts on this one would be to add this on the settings so it is completely configurable based on the current available CCK fields. Here's a rough code:

  $form['fb_social_meta']['fb_social_meta_image'] = array(
      '#title' => t('Image meta source'), 
      '#type' => 'select', 
      '#default_value' => variable_get('fb_social_meta_image', ''),
      '#description' => t('The CCK field to get the meta image from'),
      '#options' => format_content_fields(),
  );

function format_content_fields(){
  $data = array();
  $fields = content_fields();
  
  foreach ($fields as $key => $field) {
    $data[$key] = $field['field_name'];
  }
  
  return $data;
}

This gets all the available CCK fields in your system. This assumes that you only have one image in that CCK imagefield or else you need to do a loop and another set of conditions. You just need to add this using

variable_get('fb_social_meta_image','')
egomac’s picture

Here's an improved version so you can set the image source per content type:

  $form['fb_social_meta'] = array(
    '#type' => 'fieldset',
    '#title' => t('Open Graph Meta settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  
  $types = content_types();

  foreach ($types as $key => $type) {
    $form['fb_social_meta']['fb_social_meta_image_' . $key] = array(
      '#title' => t('Image meta source for ' . $type['name']), 
      '#type' => 'select', 
      '#default_value' => variable_get('fb_meta_image_' . $key, ''),
      '#description' => t('The CCK field to get the meta image value from'),
      '#options' => format_content_fields(),
    );
  }

and also limit the CCK fields to filefield type only?

function format_content_fields(){
  $data = array(''=>'Disabled');
  $fields = content_fields();
  foreach ($fields as $key => $field) {
    if ($field['type'] == 'filefield') {
      $data[$key] = $field['field_name'];
    }
  }
  return $data;
}
BigMike’s picture

This all sounds really great, to be able to control what Facebook pulls from the node. How/where can I implement the code in reply #6?

Thanks
Mike

ferdi’s picture

Status: Active » Closed (duplicate)
BigMike’s picture

Thanks ferdi!

venusrising’s picture

Status: Closed (duplicate) » Active

Is anyone currently getting # 6 to work with FB social. Running things through FB may be taxing to the server for large node sites. #8 speaks of such and an unfinished OG module.