You are here

function search_file_attachments_get_file_content in Search File Attachments 7

Extract the content of the given file.

Parameters

object $file: The file object where the content should be extracted.

Return value

string The extracted file content.

1 call to search_file_attachments_get_file_content()
search_file_attachments_update_index in ./search_file_attachments.module
Implements hook_update_index().

File

./search_file_attachments.inc, line 94
Heler functions, to hold the .module file clean and smart.

Code

function search_file_attachments_get_file_content($file) {
  $image_mimetypes = array(
    'image/jpeg',
    'image/jpg',
    'image/tiff',
  );
  if ($file->filemime == 'text/plain' || $file->filemime == 'text/x-diff') {
    $content = search_file_attachments_extract_simple($file);
  }
  elseif (in_array($file->filemime, $image_mimetypes)) {
    $content = search_file_attachments_extract_exif($file);
  }
  else {
    $content = search_file_attachments_extract_tika($file);
  }
  return (string) $content;
}