You are here

function imagepicker_image_form in Image Picker 7

Same name and namespace in other branches
  1. 5.2 imagepicker.module \imagepicker_image_form()
  2. 5 imagepicker.module \imagepicker_image_form()
  3. 6.2 imagepicker.functions.inc \imagepicker_image_form()

Function to display the image insertion form

Parameters

$img_id: The id of the image to be inserted.

$public: Optional, ensures that public images cannot be edited.

Return value

Returns the image form.

1 string reference to 'imagepicker_image_form'
imagepicker_image_select in ./imagepicker.functions.inc

File

./imagepicker.functions.inc, line 77
@author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function imagepicker_image_form($form, &$form_state, $img_id, $public = FALSE) {
  global $user;
  if (imagepicker_variable_get('imagepicker_default_align_show', 1)) {
    $form['align'] = imagepicker_get_align_opts(imagepicker_variable_get('imagepicker_insert_defaults_align', imagepicker_variable_get('imagepicker_insert_defaults_align', 'none'), $user->uid));
  }
  $form['show'] = imagepicker_get_show_opts(imagepicker_variable_get('imagepicker_insert_defaults_show', imagepicker_variable_get('imagepicker_insert_defaults_show', 'full'), $user->uid));
  $form['link'] = imagepicker_get_link_opts(imagepicker_variable_get('imagepicker_insert_defaults_link', imagepicker_variable_get('imagepicker_insert_defaults_link', 'none'), $user->uid));
  if (module_exists('image') && imagepicker_variable_get('imagepicker_image_enable', 0)) {
    $opts = image_style_options();
    $form['presets_show'] = array(
      '#type' => 'select',
      '#title' => t('Presets for Show'),
      '#options' => $opts,
      '#default_value' => imagepicker_variable_get('imagepicker_image_default_show', ''),
    );
    $form['presets_link'] = array(
      '#type' => 'select',
      '#title' => t('Presets for Link'),
      '#options' => $opts,
      '#default_value' => imagepicker_variable_get('imagepicker_image_default_link', ''),
    );
  }
  $form['desc'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Description'),
    '#description' => t('Insert title and description'),
  );

  // allow override but only if admin allows
  if (imagepicker_variable_get('imagepicker_use_cssbox', 0) && !imagepicker_variable_get('imagepicker_use_cssbox', 0, $user->uid) || imagepicker_variable_get('imagepicker_use_cssbox', 0) && imagepicker_variable_get('imagepicker_use_cssbox', 0, $user->uid)) {
    $form['cssbox'] = array(
      '#type' => 'textfield',
      '#title' => t('Add additional css'),
      '#size' => 20,
      '#description' => t('You can add additional css here, eg. class="myclass". This will be inserted into the image tag'),
    );
  }

  // rel
  if (module_exists('colorbox') && imagepicker_variable_get('imagepicker_colorbox_enable', 0)) {
    if (imagepicker_variable_get('imagepicker_use_relbox', 0) && !imagepicker_variable_get('imagepicker_use_relbox', 0, $user->uid) || imagepicker_variable_get('imagepicker_use_relbox', 0) && imagepicker_variable_get('imagepicker_use_relbox', 0, $user->uid)) {
      $form['relbox'] = array(
        '#type' => 'textfield',
        '#title' => t('Add rel attribute'),
        '#size' => 20,
        '#description' => t("You can add a rel tag here, it will be added to the link when Link 'Colorbox' is selected. Useful for creating galleries. No spaces."),
      );
      $form['linkhide'] = array(
        '#type' => 'checkbox',
        '#title' => t('Hide this link'),
        '#description' => t('Use this on subsequent links added to a gallery.'),
      );
    }
  }

  // linkbox
  if (imagepicker_variable_get('imagepicker_use_linkbox', 0) && !imagepicker_variable_get('imagepicker_use_linkbox', 0, $user->uid) || imagepicker_variable_get('imagepicker_use_linkbox', 0) && imagepicker_variable_get('imagepicker_use_linkbox', 0, $user->uid)) {
    $form['linkbox'] = array(
      '#type' => 'textfield',
      '#title' => t('Edit Link'),
      '#size' => 55,
      '#description' => t("You can edit the link here. This only applies when Link 'Page' is selected."),
      '#default_value' => '',
    );
  }
  $form['insert'] = array(
    '#type' => 'button',
    '#value' => t('Insert image'),
    '#attributes' => array(
      'onclick' => 'imagepickerInsert(this); return false;',
    ),
  );
  if (!$public) {
    $form['edit'] = array(
      '#type' => 'submit',
      '#value' => t('Edit image'),
      '#submit' => array(
        'imagepicker_image_form_edit',
      ),
    );
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete image'),
      '#submit' => array(
        'imagepicker_image_form_delete',
      ),
    );
  }
  $form['img_id'] = array(
    '#type' => 'value',
    '#value' => $img_id,
  );
  return $form;
}