You are here

function imagefield_nodeapi in ImageField 6.3

Implementation of hook_nodeapi().

Add ALT and title texts to the search index.

File

./imagefield.module, line 122

Code

function imagefield_nodeapi($node, $op) {
  if ($op == 'update index') {
    static $fields;
    if (!isset($fields)) {
      $fields = filefield_get_field_list();
    }
    $texts = array();
    foreach ($fields as $field) {
      $name = $field['field_name'];

      // Check this node for ImageField alt and title data.
      if (isset($node->{$name}) && is_array($node->{$name})) {
        foreach ($node->{$name} as $item) {
          $texts[] = isset($item['data']['alt']) ? $item['data']['alt'] : '';
          $texts[] = isset($item['data']['title']) ? $item['data']['title'] : '';
        }
      }
    }
    return implode(' ', $texts);
  }
}