Index: image.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/image.module,v retrieving revision 1.209.2.24 diff -u -p -r1.209.2.24 image.module --- image.module 12 Jun 2007 05:02:53 -0000 1.209.2.24 +++ image.module 19 Jun 2007 18:35:45 -0000 @@ -40,7 +40,7 @@ function image_node_info() { * Implementation of hook_perm */ function image_perm() { - return array('create images', 'view original images', 'edit own images', 'edit images'); + return array('create images', 'view original images', 'edit own images', 'edit images', 'download images'); } /** @@ -217,10 +217,15 @@ function image_prepare(&$node, $field_na /** * implement hook_file_download */ -function image_file_download($file) { +function image_file_download($file, $download = NULL) { + $headers = array(); $size = image_get_info(file_create_path($file)); if ($size) { - $headers = array('Content-Type: '. $size['mime_type']); + $headers[] = 'Content-Type: ' . $size['mime_type']; + if($download) { + $headers[] = 'Content-Disposition: attachment; filename="'.$file.'"'; + $headers[] = 'Content-Length: '.$size['file_size']; + } return $headers; } } @@ -241,6 +246,10 @@ function image_link($type, $node, $main if (user_access('view original images') && ($node->images[$request] != $node->images[IMAGE_ORIGINAL])) { $links['image_size_original'] = array('title' => t('original'), 'href' => 'node/'. $node->nid, 'query' => 'size='. IMAGE_ORIGINAL); } + if (user_access('download images')) { + //$links[] = l(t('download'), 'image/view/'.$node->nid.'/_original/download'); + $links['image_download'] = array('title' => t('download'), 'href' => 'image/view/'.$node->nid.'/_original/download', 'query' => 'size='. IMAGE_ORIGINAL); + } } return $links; @@ -488,7 +497,7 @@ function image_display(&$node, $label = * image/view/$nid/$label * (e.g. image/view/25/thumbnail or image/view/14) */ -function image_fetch($nid = 0, $size = 'preview') { +function image_fetch($nid = 0, $size = 'preview', $download = NULL) { if ($size == IMAGE_ORIGINAL && !user_access('view original images')) { return drupal_access_denied(); } @@ -502,7 +511,7 @@ function image_fetch($nid = 0, $size = ' if (isset($node->images[$size])) { $file = $node->images[$size]; - $headers = image_file_download($file); + $headers = image_file_download($file, $download); file_transfer($file, $headers); } }