You are here

function image_attach_form_node_type_form_alter in Image 6

Implementation of hook_form_FORM_ID_alter().

Add settings to the content type settings form.

File

contrib/image_attach/image_attach.module, line 115
image_attach.module

Code

function image_attach_form_node_type_form_alter(&$form, $form_state) {
  if ($form['#node_type']->type != 'image') {
    _image_check_settings();
    $image_sizes = array(
      IMAGE_ATTACH_HIDDEN => t('<Hidden>'),
    );
    foreach (image_get_sizes() as $key => $size) {
      $image_sizes[$key] = $size['label'];
    }
    $form['image_attach'] = array(
      '#type' => 'fieldset',
      '#title' => t('Image Attach settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['image_attach']['image_attach'] = array(
      '#type' => 'radios',
      '#title' => t('Attach images'),
      '#default_value' => variable_get('image_attach_' . $form['#node_type']->type, 0),
      '#options' => array(
        0 => t('Disabled'),
        1 => t('Enabled'),
      ),
      '#description' => t('Should this node allows users to upload an image?'),
    );
    $form['image_attach']['image_attach_maximum'] = array(
      '#type' => 'select',
      '#title' => t('Maximum number of images'),
      '#default_value' => variable_get('image_attach_maximum_' . $form['#node_type']->type, 0),
      '#options' => array(
        0 => t('Unlimited'),
      ) + drupal_map_assoc(range(1, 10)),
      '#description' => t('The maximum number of images that may be attached to nodes of this type.'),
    );
    $form['image_attach']['image_attach_size_teaser'] = array(
      '#type' => 'select',
      '#title' => t('Teaser image size'),
      '#default_value' => variable_get('image_attach_size_teaser_' . $form['#node_type']->type, IMAGE_THUMBNAIL),
      '#options' => $image_sizes,
      '#description' => t("This determines the size of the image that appears when the node is displayed as a teaser. 'Hidden' will not show the image."),
    );

    // Hide the weight if CCK is doing the weight for us.
    if (!module_exists('content')) {
      $form['image_attach']['image_attach_weight_teaser'] = array(
        '#type' => 'weight',
        '#title' => t('Teaser image weight'),
        '#default_value' => variable_get('image_attach_weight_teaser_' . $form['#node_type']->type, 0),
        '#description' => t('This value determines the order of the image when displayed in the teaser.'),
      );
    }
    $form['image_attach']['image_attach_size_body'] = array(
      '#type' => 'select',
      '#title' => t('Full node image size'),
      '#default_value' => variable_get('image_attach_size_body_' . $form['#node_type']->type, IMAGE_THUMBNAIL),
      '#options' => $image_sizes,
      '#description' => t("This determines the size of the image that appears when the full node is displayed. 'Hidden' will not show the image."),
    );
    if (!module_exists('content')) {
      $form['image_attach']['image_attach_weight_body'] = array(
        '#type' => 'weight',
        '#title' => t('Full node image weight'),
        '#default_value' => variable_get('image_attach_weight_body_' . $form['#node_type']->type, 0),
        '#description' => t('This value determines the order of the image when displayed in the body.'),
      );
    }
    if (module_exists('content')) {
      $link = l(t('Manage fields'), $_GET['q'] . '/fields');
      $form['image_attach']['#description'] = t('Since you installed CCK module, you can change the image weight in the !link page.', array(
        '!link' => $link,
      ));
    }
  }
}