You are here

function imageeditor_picmonkey_save_callback in Image Editor 7

1 string reference to 'imageeditor_picmonkey_save_callback'
picmonkey.inc in plugins/editor/picmonkey/picmonkey.inc
Picmonkey editor for Image Editor module.

File

plugins/editor/picmonkey/picmonkey.inc, line 65
Picmonkey editor for Image Editor module.

Code

function imageeditor_picmonkey_save_callback() {
  $image = '';
  if (isset($_GET['file'])) {
    $directory = imageeditor_temporary_directory();
    $data = drupal_http_request(rawurldecode($_GET['file']));
    $destination = $directory . '/' . $_COOKIE['imageeditor_filename'];
    $file = file_unmanaged_save_data($data->data, $destination, FILE_EXISTS_REPLACE);
    $image = file_create_url($file);
  }
  $js_code = 'if (parent) {';
  if (isset($_GET['_imageid'])) {
    $js_code .= 'parent.Drupal.settings.imageeditor.save.replace = ' . 1 . ';';
  }
  else {
    $js_code .= 'parent.Drupal.settings.imageeditor.save.replace = ' . 0 . ';';
  }
  $js_code .= 'parent.Drupal.settings.imageeditor.save.image = "' . $image . '";';
  $js_code .= 'parent.Drupal.imageeditor.save();';
  $js_code .= 'parent.Drupal.imageeditor.overlay.hide();';
  $js_code .= '}';
  drupal_add_js($js_code, 'inline');
}