You are here

function simple_image_rotate_widget_process in Simple Image Rotate 8

Same name and namespace in other branches
  1. 7.2 simple_image_rotate.module \simple_image_rotate_widget_process()
  2. 2.1.x simple_image_rotate.module \simple_image_rotate_widget_process()
  3. 1.0.x simple_image_rotate.module \simple_image_rotate_widget_process()
  4. 2.0.x simple_image_rotate.module \simple_image_rotate_widget_process()

Element #process callback function; process widget type image_image.

1 string reference to 'simple_image_rotate_widget_process'
simple_image_rotate_field_widget_multivalue_form_alter in ./simple_image_rotate.module
Implements hook_field_widget_multivalue_form_alter().

File

./simple_image_rotate.module, line 113
This is the Simple Image Rotate module for rotating uploaded image files.

Code

function simple_image_rotate_widget_process($element, FormStateInterface $form_state) {
  if (isset($element['#files']) && count($element['#files']) > 0) {
    $options = [
      'attributes' => [
        'title' => t('Rotate image clockwise'),
        'class' => [
          'rotate-icon',
        ],
        'data-weight' => $element['#array_parents'][2],
        'data-rotate' => 0,
        'rel' => 'nofollow',
        'data-fid' => $element['fids']['#value'][0],
      ],
    ];
    $element['rotate_link'] = Link::fromTextAndUrl(t('↻'), Url::fromUserInput('#', $options))
      ->toRenderable();
  }
  return $element;
}