You are here

function textimage_form_image_style_form_alter in Textimage 8.3

Same name and namespace in other branches
  1. 8.4 textimage.module \textimage_form_image_style_form_alter()
  2. 7.3 textimage.module \textimage_form_image_style_form_alter()

Make alterations to the core 'image_style_form' form.

A fieldset is added if the image style is Textimage relevant.

File

./textimage.module, line 178
Textimage - Provides text to image manipulations.

Code

function textimage_form_image_style_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $image_style = $form_state
    ->getFormObject()
    ->getEntity();
  $form['textimage_options'] = [
    '#type' => 'details',
    '#weight' => 10,
    '#tree' => TRUE,
    '#open' => FALSE,
    '#title' => t('Textimage options'),
    '#description' => t('Define Textimage options specific for this image style.'),
  ];

  // Define file storage wrapper used for the style images.
  $scheme_options = \Drupal::service('stream_wrapper_manager')
    ->getNames(StreamWrapperInterface::WRITE_VISIBLE);
  $form['textimage_options']['uri_scheme'] = [
    '#type' => 'radios',
    '#options' => $scheme_options,
    '#title' => t('Image destination'),
    '#description' => t('Select where Textimage image files should be stored. Private file storage has significantly more overhead than public files, but allows access restriction.'),
    '#default_value' => $image_style
      ->getThirdPartySetting('textimage', 'uri_scheme', \Drupal::service('config.factory')
      ->get('system.file')
      ->get('default_scheme')),
  ];

  // Adds a validate handler to deal with textimage options.
  $form['#validate'][] = '_textimage_form_image_style_form_validate';
}