You are here

function _filebrowser_thumbnails_generate in Filebrowser 7.2

Same name and namespace in other branches
  1. 8 filebrowser.common.inc \_filebrowser_thumbnails_generate()
  2. 6.2 includes/thumbnail.inc \_filebrowser_thumbnails_generate()
  3. 7.4 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

4 calls to _filebrowser_thumbnails_generate()
filebrowser_form_metadata in ./filebrowser.pages.inc
filebrowser_STARTER_view.tpl.php in filebrowser_STARTER/filebrowser_STARTER_view.tpl.php
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

./filebrowser.common.inc, line 600
Misc filebrowser common functions.

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",
  );
  $elligible = $module_path . "unknown.png";
  foreach ($icons as $icon) {
    if (file_exists($icon)) {
      $elligible = $icon;
      break;
    }
  }
  return theme('image', array(
    'path' => $icon,
    'alt' => 'alt text',
  ));
}