You are here

function file_style_save in Styles 7

Save a file style.

Parameters

style: An file style array.

Return value

An file style array. In the case of a new style, 'msid' will be populated.

2 calls to file_style_save()
file_style_add_form_submit in contrib/file_styles/file_styles.admin.inc
Submit handler for adding a new file style.
file_style_form_submit in contrib/file_styles/file_styles.admin.inc
Submit handler for saving a file style.

File

contrib/file_styles/file_styles.module, line 497
File widget formatter definitions.

Code

function file_style_save($style) {
  if (isset($style['msid']) && is_numeric($style['msid'])) {

    // Load the existing style to make sure we account for renamed styles.
    $old_style = image_style_load(NULL, $style['msid']);
    file_style_flush($old_style);
    drupal_write_record('file_styles', $style, 'msid');
    if ($old_style['name'] != $style['name']) {
      $style['old_name'] = $old_style['name'];
    }
  }
  else {
    drupal_write_record('file_styles', $style);
    $style['is_new'] = TRUE;
  }

  // Let other modules update as necessary on save.
  module_invoke_all('file_style_save', $style);

  // Clear all caches and flush.
  file_style_flush($style);
  return $style;
}