function media_get_thumbnail_preview in D7 Media 7.3
Same name and namespace in other branches
- 7.4 media.module \media_get_thumbnail_preview()
- 7 media.module \media_get_thumbnail_preview()
- 7.2 media.module \media_get_thumbnail_preview()
Generates a thumbnail preview of a file.
Provides default fallback images if an image of the file cannot be generated.
Parameters
object $file: A Drupal file object.
boolean $link: (optional) Boolean indicating whether the thumbnail should be linked to the file. Defaults to FALSE.
string $view_mode: (optional) The view mode to use when rendering the thumbnail. Defaults to 'preview'.
Return value
array Renderable array suitable for drupal_render() with the necessary classes and CSS to support a media thumbnail.
6 calls to media_get_thumbnail_preview()
- MediaFileFieldDisplayTestCase::testNodeDisplay in tests/
media.test - Tests normal formatter display on node display.
- media_browser_build_media_item in includes/
media.browser.inc - Adds additional properties to a file which are needed by the browser JS code.
- media_element_process in ./
media.module - Process callback for the media form element.
- media_file_edit_modal in includes/
media.pages.inc - CTools modal callback for editing a file.
- media_form_file_entity_admin_file_alter in ./
media.module - Implements hook_form_FORM_ID_alter().
File
- ./
media.module, line 1125 - Media API
Code
function media_get_thumbnail_preview($file, $link = FALSE, $view_mode = 'preview') {
// If a file has an invalid type, allow file_view_file() to work.
if (!file_type_is_enabled($file->type)) {
$file->type = file_get_type($file);
}
$preview = file_view_file($file, $view_mode);
$preview['#show_names'] = TRUE;
$preview['#add_link'] = $link;
$preview['#theme_wrappers'][] = 'media_thumbnail';
$preview['#attached']['css'][] = drupal_get_path('module', 'media') . '/css/media.css';
return $preview;
}