How to use the view_mode in hook_preprocess_flag?
view_mode key is not in variables object, which you get as argument. You can check for the same, by printing variables object.

print '&lt;pre&gt;';
print_r($variables);
print '&lt;/pre&gt;';


However if u still want to get view mode, you can use somewhat like below.

function bartik_preprocess_flag(&amp;$variables) {
  $arg_1 = arg(1);
  if( isset($arg_1) &amp;&amp; !empty($arg_1) ) {
    $menu_obj = menu_get_object();
    $menu_obj_content = $menu_obj['content'];
    foreach($menu_obj_content as $menu_key=&gt;$menu_val) {
      $node_view_mode = $menu_val['#view_mode'];
      break;
    }
    print $node_view_mode;
  }
}


Here node_view_mode will return "View Mode" of current node.