You are here

function imageblock_configure_form_validate in Image Block 6

Same name and namespace in other branches
  1. 7 imageblock.module \imageblock_configure_form_validate()
1 string reference to 'imageblock_configure_form_validate'
imageblock_form_alter in ./imageblock.module
Implements hook_form_alter().

File

./imageblock.module, line 210
imageblock.module Primarily Drupal hooks.

Code

function imageblock_configure_form_validate($form, &$form_state) {

  // TODO: make these settings, make this work
  $validators['file_validate_is_image'] = array();
  if ($max = variable_get('imageblock_max_file_size', 0)) {
    $validators['file_validate_size'] = array(
      parse_size($max),
      0,
    );
  }
  if ($max = variable_get('imageblock_max_dimensions', 0)) {
    $validators['file_validate_image_resolution'] = array(
      $max,
    );
  }

  // Save new file uploads.
  $file = file_save_upload('imageblock', $validators, file_directory_path());
  if (!$file) {
    return;
  }
  $form_state['values']['imageblock_file'] = $file;
}