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

Add to files as they are viewed.

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


File $file: The fully loaded file object

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


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


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);