You are here

function _filebrowser_thumbnails_generate in Filebrowser 6.2

Same name and namespace in other branches
  1. 8 filebrowser.common.inc \_filebrowser_thumbnails_generate()
  2. 7.4 filebrowser.common.inc \_filebrowser_thumbnails_generate()
  3. 7.2 filebrowser.common.inc \_filebrowser_thumbnails_generate()
  4. 7.3 filebrowser.common.inc \_filebrowser_thumbnails_generate()

Create a thumbnail and the associated XHTML code for a specific file.

Parameters

$node source node:

$file source file:

Return value

XHTML code

3 calls to _filebrowser_thumbnails_generate()
filebrowser_form_metadata in ./filebrowser.pages.inc
theme_dir_listing_icon_view in ./filebrowser.theme.inc
Enter description here ...
theme_dir_listing_list_view in ./filebrowser.theme.inc
Theming function for list view.

File

includes/thumbnail.inc, line 31

Code

function _filebrowser_thumbnails_generate(&$node, &$file) {
  static $thumbnailers = NULL;
  if (!$thumbnailers) {
    $thumbnailers = module_implements("filebrowser_thumbnailer_get");
  }
  if (count($thumbnailers) != 0) {
    foreach ($thumbnailers as $thumbnailer) {
      if ($node->file_handlers->{$thumbnailer}->enabled_thumbnailer) {
        $thumbnail = module_invoke($thumbnailer, "filebrowser_thumbnailer_get", $file, $node->file_handlers->{$thumbnailer});
        if ($thumbnail) {
          return $thumbnail;
        }
      }
    }
  }
  $main_type = dirname($file['mime-type']);
  $mime_type = str_replace("/", "-", $file['mime-type']);
  $module_path = drupal_get_path("module", "filebrowser") . "/icons/";
  $theme_path = drupal_get_path('theme', $GLOBALS['theme']) . "/filebrowser/";
  $icons = array(
    $theme_path . $mime_type . ".png",
    $theme_path . $main_type . ".png",
    $module_path . $mime_type . ".png",
    $module_path . $main_type . ".png",
  );
  foreach ($icons as $icon) {
    if (file_exists($icon)) {
      return theme('image', $icon);
    }
  }
  return theme('image', $module_path . "unknown.png");
}