*************** *** 64,88 **** // if enabled adjust the form case $type .'_node_form': if ($enabled == 1 && function_exists('_image_check_settings')) { _image_check_settings(); $node = $form['#node']; $form['#attributes'] = array("enctype" => "multipart/form-data"); - $form['image_attach'] = array('#type' => 'fieldset', '#title' => t('Attached Images'), '#collapsible' => TRUE); if ($node->iid) { $image = node_load($node->iid); - $form['image_attach']['image_thumbnail'] = array('#type' => 'item', '#title' => t('Thumbnail'), '#value' => image_display($image, 'thumbnail')); } - $value = ($node->new_image) ? '#value' : '#default_value'; - $form['image_attach']['iid'] = array('#type' => 'hidden' , $value => $node->iid); - $form['image_attach']['image'] = array('#type' => 'file', '#title' => t('Image')); - $form['image_attach']['image_title'] = array('#type' => 'textfield', '#title' => t('Image title'), '#default_value' => $image->title); } break; } } /** * Implementation of hook_nodeapi(). */ function image_attach_nodeapi(&$node, $op, $teaser, $page) { --- 81,182 ---- // if enabled adjust the form case $type .'_node_form': if ($enabled == 1 && function_exists('_image_check_settings')) { + $existing = !variable_get('existingImageAttachDisabled', 0); _image_check_settings(); $node = $form['#node']; $form['#attributes'] = array("enctype" => "multipart/form-data"); + $form['image_attach'] = array( + '#type' => 'fieldset', + '#title' => t('Attached Images'), + '#collapsible' => TRUE, + '#collapsed' => !$node->iid + ); if ($node->iid) { $image = node_load($node->iid); + $form['image_attach']['image_thumbnail'] = array( + '#type' => 'item', + '#title' => t('Thumbnail'), + '#value' => image_display($image, 'thumbnail') + ); } + $form['image_attach']['image'] = array( + '#type' => 'file', + '#title' => t('Upload Image') + ); + if (module_exist('image_gallery')) { + $form['image_attach']['image_gallery'] = taxonomy_form(_image_gallery_get_vid()); + $form['image_attach']['image_gallery']['#weight'] = 0; // Override weight to keep it here + $form['image_attach']['image_gallery']['#description'] = t('Choose an image gallery to place the new image in.'); + } + $form['image_attach']['image_title'] = array( + '#type' => 'textfield', + '#title' => t('Image title'), + '#default_value' => '', + '#description' => t('The title the image will be shown with.') + ); + if ($existing && user_access('access content')) { + $form['image_attach'][] = array( + '#type' => 'item', + '#value' => t('-or-'), + '#attributes' => array('class' => 'either-choice') + ); + $form['image_attach']['iid'] = array( + '#type' => 'select', + '#title' => t('Existing Image'), + '#options' => _image_attach_get_image_nodes(), + '#default_value' => $node->iid, + '#description' => t('Choose an image already existing on the server if you do not upload a new one.') + ); + $form['image_attach'][] = array( + '#value' => << + + EOD + ); + } } break; } } /** + * Implementation of hook_menu() + */ + function image_attach_menu($may_cache) { + $items = array(); + + if ($may_cache) { + $items[] = array('path' => 'image_attach', + 'title' => t('Image Attachment View'), + 'callback' => 'image_attach_view_image', + 'access' => user_access('access content'), + 'type' => MENU_CALLBACK, + ); + } + return $items; + } + + /** * Implementation of hook_nodeapi(). */ function image_attach_nodeapi(&$node, $op, $teaser, $page) { *************** *** 96,112 **** $image->name = $node->name; $image->created = $node->created; $image->type = 'image'; image_prepare($image, 'image'); if ($image->images) { node_validate($image); if (!form_get_errors()) { $image = node_submit($image); node_save($image); $node->iid = $image->nid; $node->new_image = TRUE; } } - elseif ($_POST['edit']['iid']) { $node->iid = $_POST['edit']['iid']; } break; --- 190,212 ---- $image->name = $node->name; $image->created = $node->created; $image->type = 'image'; + $gallery = taxonomy_get_term($_POST['edit']['image_gallery']); + if ($gallery) + $image->taxonomy = array($gallery->tid => $gallery); + else + $image->taxonomy = array(); image_prepare($image, 'image'); if ($image->images) { node_validate($image); if (!form_get_errors()) { $image = node_submit($image); node_save($image); + taxonomy_node_save($image->nid, $image->taxonomy); $node->iid = $image->nid; $node->new_image = TRUE; } } + elseif (!variable_get('existingImageAttachDisabled', 0) && $_POST['edit']['iid']) { $node->iid = $_POST['edit']['iid']; } break;