function _image_import_batch_op in Image 7
Same name and namespace in other branches
- 6 contrib/image_import/image_import.pages.inc \_image_import_batch_op()
Batch operation callback for image import.
1 string reference to '_image_import_batch_op'
- image_import_form_submit in contrib/
image_import/ image_import.pages.inc - Submit handler for the image import form.
File
- contrib/
image_import/ image_import.pages.inc, line 238
Code
function _image_import_batch_op($args, &$context) {
$error = FALSE;
// if user choses to reproduce directories structure, save the chosen gallery,
// then create, if needed, the nested galleries where the image goes
if ($args['subgallery']) {
static $subgalleries = array();
$image_galleries_vid = _image_gallery_get_vid();
$subgalleries_parent_tid = $args['taxonomy'][$image_galleries_vid];
$args['taxonomy'][$image_galleries_vid] = _image_import_create_subgalleries($args['origname'], $image_galleries_vid, $subgalleries_parent_tid, $subgalleries, $context);
if (!$args['taxonomy'][$image_galleries_vid]) {
$error = TRUE;
}
}
// Create the node object.
if (!$error && ($node = image_create_node_from($args['filepath'], $args['title'], $args['body'], $args['taxonomy']))) {
// Remove the original image now that the import has completed.
file_delete($args['filepath']);
$context['results']['good'][] = t('Imported %origname as !link @status [!edit-link].', array(
'%origname' => $args['origname'],
'!link' => l($node->title, 'node/' . $node->nid),
'@status' => $node->status ? '' : t('(Unpublished)'),
'!edit-link' => l(t('edit'), 'node/' . $node->nid . '/edit'),
));
}
else {
watchdog('image_import', 'There was an error that prevented %filename from being imported.', array(
'%filename' => $args['filepath'],
), WATCHDOG_ERROR);
$context['results']['bad'][] = t('Error importing %filename.', array(
'%filename' => $args['filepath'],
));
}
$context['finished'] = 1;
}