diff --git a/file_entity.file_api.inc b/file_entity.file_api.inc index 428192b..f319281 100644 --- a/file_entity.file_api.inc +++ b/file_entity.file_api.inc @@ -298,16 +298,21 @@ function file_view_file($file, $displays = 'full', $langcode = NULL) { } } - // If a render element was returned by a formatter or the file type's default - // view callback, add some defaults to it and return it. - if (isset($element)) { - $element += array( + // As a last resort, fall back to showing a link to the file. + if (!isset($element)) { + $element = array( + '#theme' => 'file_link', '#file' => $file, - '#view_mode' => $view_mode, - '#language' => $langcode, ); - return $element; } + + // Add defaults and return the element. + $element += array( + '#file' => $file, + '#view_mode' => $view_mode, + '#language' => $langcode, + ); + return $element; } /** diff --git a/file_entity.module b/file_entity.module index cd35d9a..4090290 100644 --- a/file_entity.module +++ b/file_entity.module @@ -214,9 +214,19 @@ function file_entity_entity_info_alter(&$entity_info) { $entity_info['file']['fieldable'] = TRUE; $entity_info['file']['entity keys']['bundle'] = 'type'; $entity_info['file']['bundles'] = array(); - $entity_info['file']['view modes']['full'] = array( - 'label' => t('Full'), - 'custom settings' => FALSE, + $entity_info['file']['view modes'] += array( + 'full' => array( + 'label' => t('Full'), + 'custom settings' => FALSE, + ), + 'teaser' => array( + 'label' => t('Teaser'), + 'custom settings' => FALSE, + ), + 'preview' => array( + 'label' => t('Preview'), + 'custom settings' => FALSE, + ), ); foreach (file_info_file_types() as $type => $info) { $info += array( diff --git a/file_entity.pages.inc b/file_entity.pages.inc index 43f9cff..d425940 100644 --- a/file_entity.pages.inc +++ b/file_entity.pages.inc @@ -38,10 +38,7 @@ function file_entity_edit($form, $form_state, $file) { $form_state['file'] = $file; field_attach_form('file', $file, $form, $form_state); - $form['preview'] = array( - '#theme' => 'file_link', - '#file' => $file, - ); + $form['preview'] = file_view_file($file, 'preview'); // Add the buttons. $form['actions'] = array('#type' => 'actions');