You are here

function _itweak_upload_files_thumbnails in iTweak Upload 6.2

Similar to _itweak_upload_preprocess_files(), only works on already prepared form

Parameters

$files: Array of file objects, same type as nodeapi 'view' "if ($node->nid) foreach ($node->files as $fid => $file) ..."

$vid: File's parent node vid (version id).

$cid: File's parent comment cid (comment id), if file is uploaded to a comment.

$node_type: Node type.

$group: Group name for handler grouping option

2 calls to _itweak_upload_files_thumbnails()
itweak_upload_form_alter in ./itweak_upload.module
Implementation of hook_form_alter().
_itweak_upload_upload_form_prerender in ./itweak_upload.module
Worker code for itweak_upload_form_alter(). Modify a bit the attachment fieldset, add js.

File

./itweak_upload.module, line 216
iTweakUpload - Tweak attachments display and file upload forms.

Code

function _itweak_upload_files_thumbnails(&$files, $vid, $cid, $node_type, $group) {
  $derivative = _itweak_upload_get_derivative('upload', $node_type);
  $show_title = _itweak_upload_get_setting('thumbnail_title', '', $node_type, 1);

  // Build list of attached files and filter out images.
  foreach (element_children($files) as $fid) {
    $file = new stdClass();
    $file->fid = $files[$fid]['fid']['#value'];
    $file->filename = $files[$fid]['filename']['#value'];
    $file->filepath = $files[$fid]['filepath']['#value'];
    $file->filemime = $files[$fid]['filemime']['#value'];
    $file->filesize = $files[$fid]['filesize']['#value'];
    $file->vid = $vid;
    $file->cid = $cid;
    $file->description = $files[$fid]['description']['#default_value'];
    $file->list = $files[$fid]['list']['#default_value'];
    $options = _itweak_upload_get_link_options($file, 'upload', $node_type, $group);

    // No caption (this only gets called from upload forms, where form itself shows file name)
    $preview = module_invoke_all('itweak_upload_preview', $file, $derivative, $show_title, FALSE, $options);
    if ($preview) {
      $files[$fid]['preview'] = $preview;
    }
  }
}