function imageapi_optimize_pipeline_save in Image Optimize (or ImageAPI Optimize) 7.2
Saves an image pipeline.
Parameters
array $pipeline: An image pipeline array containing:
- name: A unique name for the pipeline.
- isid: (optional) An image pipeline ID.
Return value
array An image pipeline array containing:
- name: An unique name for the pipeline.
- old_name: The original name for the pipeline.
- isid: An image pipeline ID.
- is_new: TRUE if this is a new pipeline, and FALSE if it is an existing pipeline.
3 calls to imageapi_optimize_pipeline_save()
- imageapi_optimize_default_pipeline_save in ./
imageapi_optimize.module - Saves a default image pipeline to the database.
- imageapi_optimize_pipeline_add_form_submit in ./
imageapi_optimize.admin.inc - Submit handler for adding a new image pipeline.
- imageapi_optimize_pipeline_form_submit in ./
imageapi_optimize.admin.inc - Submit handler for saving an image pipeline.
File
- ./
imageapi_optimize.module, line 346
Code
function imageapi_optimize_pipeline_save($pipeline) {
if (isset($pipeline['isid']) && is_numeric($pipeline['isid'])) {
// Load the existing pipeline to make sure we account for renamed pipelines.
$old_pipeline = imageapi_optimize_pipeline_load(NULL, $pipeline['isid']);
imageapi_optimize_pipeline_flush($old_pipeline);
drupal_write_record('imageapi_optimize_pipelines', $pipeline, 'isid');
if ($old_pipeline['name'] != $pipeline['name']) {
$pipeline['old_name'] = $old_pipeline['name'];
}
}
else {
// Add a default label when not given.
if (empty($pipeline['label'])) {
$pipeline['label'] = $pipeline['name'];
}
drupal_write_record('imageapi_optimize_pipelines', $pipeline);
$pipeline['is_new'] = TRUE;
}
// Let other modules update as necessary on save.
module_invoke_all('imageapi_optimize_pipeline_save', $pipeline);
// Clear all caches and flush.
imageapi_optimize_pipeline_flush($pipeline);
return $pipeline;
}