diff --git a/file_entity.file_api.inc b/file_entity.file_api.inc index 9a1c102..3f28b9e 100644 --- a/file_entity.file_api.inc +++ b/file_entity.file_api.inc @@ -308,16 +308,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 778b2d9..cd71ccf 100644 --- a/file_entity.module +++ b/file_entity.module @@ -215,10 +215,21 @@ function file_entity_entity_info_alter(&$entity_info) { $entity_info['file']['entity keys']['bundle'] = 'type'; $entity_info['file']['bundles'] = array(); $entity_info['file']['uri callback'] = 'file_entity_uri'; - $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( // Provide a default administration path for Field UI, but not if 'admin' diff --git a/file_entity.pages.inc b/file_entity.pages.inc index 6717f85..ec6e088 100644 --- a/file_entity.pages.inc +++ b/file_entity.pages.inc @@ -60,11 +60,7 @@ function file_entity_edit($form, &$form_state, $file) { '#weight' => -10, ); - $form['preview'] = array( - '#theme' => 'file_link', - '#file' => $file, - '#weight' => -5, - ); + $form['preview'] = file_view_file($file, 'preview'); // Add the buttons. $form['actions'] = array('#type' => 'actions');