You are here

function imageeditor_svgedit_save_callback in Image Editor 7

1 string reference to 'imageeditor_svgedit_save_callback'
svgedit.inc in plugins/editor/svgedit/svgedit.inc
SVG-edit editor for Image Editor module.

File

plugins/editor/svgedit/svgedit.inc, line 39
SVG-edit editor for Image Editor module.

Code

function imageeditor_svgedit_save_callback() {
  $directory = imageeditor_temporary_directory();
  $image = '';
  if (isset($_POST['output_png'])) {
    $destination = $directory . '/' . md5($_POST['output_png']) . '.png';
    $file = file_unmanaged_save_data(base64_decode(substr($_POST['output_png'], 22)), $destination);
    $image = file_create_url($file);
  }
  elseif (isset($_POST['output_svg'])) {
    $destination = $directory . '/' . md5($_POST['output_svg']) . '.svg';
    $file = file_unmanaged_save_data(urldecode($_POST['output_svg']), $destination);
    $image = file_create_url($file);
  }
  $js_code = 'if (parent.parent) {';
  $js_code .= 'parent.parent.Drupal.settings.imageeditor.save.image = "' . $image . '";';
  $js_code .= 'parent.parent.Drupal.imageeditor.save();';
  $js_code .= 'parent.parent.Drupal.imageeditor.overlay.hide();';
  $js_code .= '}';
  drupal_add_js($js_code, 'inline');
}