function manualcrop_save_crop_data in Manual Crop 7
Save the Manual Crop data for a file.
Parameters
$file: The file entity being saved for.
$data: The data as it is to be written, keyed by style name.
2 calls to manualcrop_save_crop_data()
- manualcrop_croptool_submit in ./
manualcrop.module - Form submit handler; Saves each crop selection.
- manualcrop_entity_update in ./
manualcrop.module - Implements hook_file_entity_update().
File
- ./
manualcrop.helpers.inc, line 596 - Helper functions for the Manual Crop module.
Code
function manualcrop_save_crop_data($file, $data) {
// If file_entity_revisions isn't enabled, use 0.
$vid = isset($file->vid) ? $file->vid : 0;
// Delete the existing data.
db_delete('manualcrop')
->condition('fid', $file->fid)
->condition('vid', $vid)
->condition('style_name', array_keys($data))
->execute();
// Save the new crop selections.
foreach ($data as $style_name => $selection) {
if ($selection) {
$record = array_merge($selection, array(
'fid' => $file->fid,
'vid' => $vid,
'style_name' => $style_name,
));
drupal_write_record('manualcrop', $record);
}
}
}