You are here

function video_image_form_alter in Video 6.2

Same name and namespace in other branches
  1. 5 plugins/video_image/video_image.module \video_image_form_alter()
  2. 6 plugins/video_image/video_image.module \video_image_form_alter()

Implementation of hook_form_alter()

File

plugins/video_image/video_image.module, line 140
Enable image support for video module.

Code

function video_image_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'video_node_form') {
    $node = $form['#node'];
    $value = $node->new_image ? '#value' : '#default_value';
    $form['iid'] = array(
      '#type' => 'hidden',
      $value => $node->iid,
    );
    if (!is_array($node->tempimage['fids'])) {
      $fids = array(
        '_original' => 0,
      );
      foreach (_image_get_sizes() as $size) {
        $fids[$size['label']] = 0;
      }
      $node->tempimage['fids'] = $fids;
    }
    $form['tempimage']['#tree'] = true;
    foreach ($node->tempimage['fids'] as $label => $fid) {
      $form['tempimage']['fids'][$label] = array(
        '#type' => 'hidden',
        $value => $fid,
      );
    }
    $auto_thumbable = video_image_is_autothumbable($node);

    //echo ''.$auto_thumbable;

    //GMM: fix permission misspelling

    // TODO : set correct permission
    $perm = video_image_perm();
    if (!$auto_thumbable || user_access($perm[OVERRIDE_IMAGE])) {

      // let's be sure that image directories are ready
      if (function_exists('_image_check_settings')) {
        _image_check_settings();
      }

      // needed for uploading
      $form['#attributes'] = array(
        "enctype" => "multipart/form-data",
      );
      $form['image'] = array(
        '#type' => 'fieldset',
        '#title' => t('Image thumbnails'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#weight' => -17,
        '#description' => t('Upload an image to be used as the thumbnail for this video.'),
      );
      $form['image']['image'] = array(
        '#type' => 'file',
        '#title' => t('Image'),
      );
    }
    if ($node->nid && $auto_thumbable) {
      $form['regenerate_thumbnail'] = array(
        '#type' => 'checkbox',
        '#title' => t('Auto regenerate thumbnail'),
        '#default_value' => 0,
      );
    }
  }
}