You are here

function textimage_js_preview in Textimage 7.2

Same name and namespace in other branches
  1. 5.2 textimage.module \textimage_js_preview()
  2. 6.2 textimage.module \textimage_js_preview()

Textimage preview AJAX functionality.

1 string reference to 'textimage_js_preview'
textimage_preset_edit in ./textimage.admin.inc
Todo.

File

./textimage.module, line 851
Provides text to image manipulations.

Code

function textimage_js_preview($form, $form_state) {
  $preview['settings'] = $form_state['values']['settings'];
  $preview['name'] = $form_state['values']['name'];
  $preview['description'] = $form_state['values']['description'];
  $preview['pid'] = 0;
  $preview_text = isset($preview['settings']['preview']['text']['default']) ? $preview['settings']['preview']['text']['default'] : t('Preview');
  $additional_text = array();
  if (isset($preset['settings']['preview']['text']['additional'])) {
    $additional_text = $preset['settings']['preview']['text']['additional'];
    rsort($additional_text);
  }
  $preview = textimage_build_preview(array(
    'preset' => $preview,
    'text' => $preview_text,
    'additional_text' => $additional_text,
  ));
  $commands = array();
  $commands[] = ajax_command_html('#textimage-preview', '<img src="' . file_create_url($preview) . '?' . time() . '">');
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}