--- image_old.module 2006-04-24 17:01:28.000000000 -0500 +++ image.module 2006-04-24 17:06:35.000000000 -0500 @@ -39,7 +39,7 @@ function image_node_info() { * Implementation of hook_perm */ function image_perm() { - return array('administer images', 'create images', 'view original images'); + return array('administer images', 'create images', 'view original images', 'download images'); } /** @@ -188,10 +188,12 @@ function image_prepare(&$node, $field_na /** * implement hook_file_download */ -function image_file_download($file) { +function image_file_download($file, $dl = NULL) { $size = image_get_info(file_create_path($file)); if ($size) { $headers = array('Content-Type: ' . $size['mime_type']); + if($dl) + $headers[] = 'Content-Disposition: attachment; filename="'.$file.'"'; return $headers; } } @@ -212,6 +214,8 @@ function image_link($type, $node, $main if (user_access('view original images') && ($node->images[$request] != $node->images['_original'])) { $links[] = l(t('original'), 'node/' . $node->nid, NULL, 'size=_original'); } + if(user_access('download images')) + $links[] = l(t('download'), 'image/view/'.$node->nid.'/_original/download'); } return $links; @@ -404,12 +408,12 @@ 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', $dl = NULL) { if ($nid) { $node = node_load(array('nid' => $nid)); if ($node->images[$size]) { $file = $node->images[$size]; - $headers = image_file_download($file); + $headers = image_file_download($file, $dl); file_transfer($file, $headers); } }