It seems the module no longer creates a node for the image using the image module, but instead just uploads a file that is not associated with a node. It would be nice to have this functionality back, as well as support for CCK-created image content-types (photo in my case). It would be even better if this upload were a form of some sort, so users could add a description, select taxonomy, etc.
The old code
/**
* Use 'Image' module to create an image node and update derivatives.
*/
function imagebrowser_upload_submit($form_id, $form_values) {
$file = file_save_upload('upload'); //Save temp file
if (filesize($file->filepath) > (variable_get('image_max_upload_size', 800)*1024)) {
drupal_set_message(t('Image larger than acceptable limit.'), 'error');
return FALSE;
}
$node = image_create_node_from($file->filepath, NULL, '', NULL); //Create Image node
$node = node_load($node->nid); //We need to reload the node for some reason (bug with image_create_node_from?)
if ($node == FALSE) {
drupal_get_messages();
drupal_set_message(t('Image failed to upload. Please try again.'), 'error');
}
else {
image_update($node); //Update the derivatives
drupal_get_messages();
drupal_set_message(t('New image uploaded successfully.'));
}
}
Comments
Comment #1
pyrollo commentedI'm also interested in that. It can be related to the link to node feature (as we need a node to link with) : http://drupal.org/node/683432
I may have a look at how to put that back in the code...
Comment #2
pyrollo commentedThis is done, I posted a patch at http://drupal.org/node/683432 that creates an image node for uploaded images if image module is present. Furthermore it allows to have image linked to its image node.
Comment #3
peter törnstrand commentedSee #683432: Image link to image node