You are here

public function TextOverlayImageEffect::processAjaxPreview in Image Effects 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageEffect/TextOverlayImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\TextOverlayImageEffect::processAjaxPreview()
  2. 8.2 src/Plugin/ImageEffect/TextOverlayImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\TextOverlayImageEffect::processAjaxPreview()

Preview Ajax callback.

File

src/Plugin/ImageEffect/TextOverlayImageEffect.php, line 653

Class

TextOverlayImageEffect
Overlays text on the image, defining text font, size and positioning.

Namespace

Drupal\image_effects\Plugin\ImageEffect

Code

public function processAjaxPreview($form, FormStateInterface $form_state) {
  list($success, $preview) = $this
    ->buildPreviewRender($form_state
    ->getValue([
    'data',
    'ajax_config',
  ]));
  $preview_render = [
    '#theme' => 'image_effects_text_overlay_preview',
    '#success' => $success,
    '#preview' => $preview,
  ];
  $response = new AjaxResponse();
  $response
    ->addCommand(new ReplaceCommand('#text-overlay-preview', $preview_render));
  return $response;
}