1 file.api.php hook_file_update_index($file)

Act on a file being indexed for searching.

This hook is invoked during search indexing, after file_load(), and after the result of file_view() is added as $file->rendered to the file object.

Parameters

object $file: The file being indexed.

Return value

string: Additional file information to be indexed.

File

core/modules/file/file.api.php, line 326
Hooks for file module.

Code

function hook_file_update_index($file) {
  $text = '';
  $uses = db_query('SELECT module, count FROM {file_usage} WHERE fid = :fid', array(':fid' => $file->fid));
  foreach ($uses as $use) {
    $text .= '<h2>' . check_plain($use->module) . '</h2>' . check_plain($use->count);
  }
  return $text;
}