You are here

function qtip_field_preprocess_field in qTip (Stylish jQuery Tooltips) 7.2

Implements hook_preprocess_field().

File

modules/qtip_field/qtip_field.module, line 167

Code

function qtip_field_preprocess_field(&$variables) {
  $settings = field_info_instance($variables['element']['#entity_type'], $variables['element']['#field_name'], $variables['element']['#bundle']);
  if ($variables['label_hidden'] == FALSE && isset($settings['qtip']) && $settings['qtip']['qtip_label'] === 1 && $settings['qtip']['text'] != 'none') {
    $qtip_help_image = theme('image', array(
      'path' => base_path() . 'misc/help.png',
    ));
    $tooltip_text = '';
    switch ($settings['qtip']['text']) {
      case 'description':
        if (isset($settings['description'])) {
          $tooltip_text = $settings['description'];
        }
        break;
      case 'custom':
        $tooltip_text = isset($settings['qtip']['custom_text']) ? $settings['qtip']['custom_text'] : '';
        break;
    }
    $qtip = theme('qtip', array(
      'content' => $qtip_help_image,
      'instance' => $settings['qtip']['instance'],
      'tooltip' => $tooltip_text,
    ));
    $variables['label'] = $variables['label'] . $qtip;
  }
}