You are here

function filebrowser_update_thumbnails in Filebrowser 7.2

Same name and namespace in other branches
  1. 8 filebrowser.pages.inc \filebrowser_update_thumbnails()
  2. 6.2 filebrowser.pages.inc \filebrowser_update_thumbnails()
  3. 7.4 filebrowser.pages.inc \filebrowser_update_thumbnails()
  4. 7.3 filebrowser.pages.inc \filebrowser_update_thumbnails()
1 call to filebrowser_update_thumbnails()
filebrowser_node_mass_update_thumbnails in ./filebrowser.module
1 string reference to 'filebrowser_update_thumbnails'
filebrowser_menu in ./filebrowser.module

File

./filebrowser.pages.inc, line 151
Several support functions for filebrowser

Code

function filebrowser_update_thumbnails($fids) {
  if (!is_array($fids)) {
    $fids = array(
      $fids,
    );
  }
  $batch = array(
    'operations' => array(),
    'title' => t('Processing Thumbnail Updating'),
    'init_message' => t('Thumbnail updating is starting.'),
    'progress_message' => t('Processed @current out of @total thumbnails.'),
    'error_message' => t('Thumbnail updating has encountered an error.'),
  );
  $thumbnailers = module_implements("filebrowser_thumbnailer_prepare");
  foreach ($fids as $fid) {
    $content = _filebrowser_node_content_load($fid);
    $node = node_load($content['nid']);
    _filebrowser_load_files($node, $fid);
    foreach ($node->file_listing as $name => &$file) {
      module_invoke($thumbnailer, "filebrowser_thumbnailer_cleanup", $node);
      foreach ($thumbnailers as $thumbnailer) {
        if ($node->file_handlers->{$thumbnailer}->enabled_thumbnailer) {
          $operations = module_invoke($thumbnailer, "filebrowser_thumbnailer_prepare", $file, $node->file_handlers->{$thumbnailer});
          if ($operations && count($operations)) {
            $batch['operations'] = array_merge($batch['operations'], $operations);
          }
        }
      }
    }
  }

  //   echo "<pre>"; var_dump($batch); exit();
  if (count($batch['operations'])) {
    batch_set($batch);
    batch_process($_GET['destination']);
  }
  else {
    drupal_set_message(t("No operation needed for thumbnail updating"));
  }
}