1 file.api.php hook_file_view($file, $view_mode, $langcode)

Add to files as they are viewed.

@langcode string A language code indiciating the language used to render the file.

Parameters

File $file: The fully loaded file object

string $view_mode: The machhine name of the Display mode for viewing the file.

File

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

Code

function hook_file_view($file, $view_mode, $langcode) {
  // Add a contextual link to edit the file.
  if ($view_mode != 'full' && $view_mode != 'preview') {
    $file->content['links']['file']['#links']['edit'] = l(t('Edit'), 'file/' . $file->fid);
  }
}