function media_admin_thumbnails in D7 Media 7
Form builder: Builds the media thumbnails administration overview.
1 string reference to 'media_admin_thumbnails'
- media_media_display_types in ./
media.media.inc - Implements hook_media_display_types().
File
- includes/
media.admin.inc, line 165 - This file contains the admin functions for the Media module.
Code
function media_admin_thumbnails(&$parent_form) {
// @todo Change to media_variable_get('admin_pager_limit') for consistency
// with browser_pager_limit?
$limit = variable_get('media_admin_limit', 50);
$query = db_select('file_managed', 'f')
->extend('PagerDefault');
$query
->fields('f', array(
'fid',
));
$query
->condition('f.status', FILE_STATUS_PERMANENT);
$query
->limit($limit);
$query
->orderBy('f.timestamp', 'DESC');
foreach (array_keys(media_get_hidden_stream_wrappers()) as $name) {
$query
->condition('f.uri', $name . '%', 'NOT LIKE');
}
$fids = $query
->execute()
->fetchCol();
$files = file_load_multiple($fids);
// Hide the operations form if there are no files to operate on.
$parent_form['options']['#access'] &= !empty($files);
if (empty($files)) {
// Display empty text if there are no files.
$form['files'] = array(
'#markup' => '<p>' . t('No media available.') . '</p>',
);
}
else {
$form['files'] = array(
'#tree' => TRUE,
'#prefix' => '<div class="media-display-thumbnails media-clear clearfix"><ul class="media-list-thumbnails">',
'#suffix' => '</ul></div>',
);
foreach ($files as $file) {
$preview = media_get_thumbnail_preview($file, TRUE);
$form['files'][$file->fid] = array(
'#type' => 'checkbox',
'#title' => '',
'#prefix' => '<li>' . drupal_render($preview),
'#suffix' => '</li>',
);
}
$form['pager'] = array(
'#markup' => theme('pager', array(
'tags' => NULL,
)),
);
}
return $form;
}