You are here

function theme_image_attach_form_thumbnails in Image 6

Theme image thumbnails in editing ui to a drag-to-reorder table

Parameters

$form: The $form object

File

contrib/image_attach/image_attach.module, line 653
image_attach.module

Code

function theme_image_attach_form_thumbnails($form) {
  drupal_add_tabledrag('image-attach-thumbnails-draggable-table', 'order', 'sibling', 'weight');
  $header = array(
    t('Attached images'),
    t('Remove'),
    t('Title'),
    t('Weight'),
  );
  foreach (element_children($form) as $key) {
    $element =& $form[$key];
    $element['weight']['#attributes']['class'] = 'weight';
    $row = array();
    $row[] = drupal_render($element['image']);
    $row[] = drupal_render($element['delete']);
    $row[] = drupal_render($element['title']);
    $row[] = drupal_render($element['weight']) . drupal_render($element['id']);
    $rows[] = array(
      'data' => $row,
      'class' => 'draggable',
    );
  }
  $output = theme('table', $header, $rows, array(
    'id' => 'image-attach-thumbnails-draggable-table',
  ));
  $output .= drupal_render($form);
  return $output;
}