You are here

function ml_image_basic_upload_options_form in Media Library 6

Function for upload options (second step) {

File

ml_image/ml_image_basic/ml_image_basic.module, line 246
This module aims to provide some basic sources for images to use with Media Library, such as navigating on existing files and uploading new images

Code

function ml_image_basic_upload_options_form($form_state) {
  $form = array();
  $metadata = ml_image_get_metadata();
  foreach ($metadata as $field => $data) {
    switch ($data['type']) {
      case 'textfield':
      case 'textarea':
        $form[$field] = array(
          '#type' => $data['type'],
          '#title' => $data['label'],
          '#description' => $data['description'],
        );
        break;
      case 'term':
        $vocabulary = $data['vocabulary'];
        if ($vocabulary->tags) {
          $form[$field] = array(
            '#type' => 'textfield',
            '#title' => $data['label'],
            '#description' => $data['description'],
            '#autocomplete_path' => 'taxonomy/autocomplete/' . $vocabulary->vid,
            '#maxlength' => 1024,
          );
        }
        else {

          // Extract terms belonging to the vocabulary in question.
          $form[$field] = taxonomy_form($vocabulary->vid, array(), $data['description']);
          $form[$field]['#title'] = $data['title'];
        }
        break;
    }
  }
  return $form;
}