Index: image.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/image.module,v retrieving revision 1.197.2.2 diff -u -F^f -r1.197.2.2 image.module --- image.module 18 Jul 2006 14:00:52 -0000 1.197.2.2 +++ image.module 14 Aug 2006 07:49:58 -0000 @@ -334,6 +334,31 @@ function image_delete($node) { } /** + * Implementation of hook_views_tables() + */ +function image_views_tables() { + $tables['image'] = array( + 'name' => 'node', + 'fields' => array( + 'nid' => array( + 'name' => t('Image: Display Image'), + 'handler' => array( + 'image_views_handler_image_img' => t('Image'), + 'image_views_handler_image_img_link' => t('Image with link'), + ), + 'option' => array( + '#type' => 'select', + '#options' => 'image_views_handler_filter_image_size', + ), + 'notafield' => true, + 'sortable' => false, + ), + ), + ); + return $tables; +} + +/** * Create an tag for an image. */ function image_display(&$node, $label = 'preview', $attributes = array()) { @@ -429,6 +454,33 @@ function image_get_latest($count = 1, $t } /** + * Views handler for displaying the image. + */ +function image_views_handler_image_img($fieldinfo, $fielddata, $value, $data) { + $node = node_load($data->nid); + return image_display($node, $fielddata['options']); +} + +/** + * Views handler for displaying the image in a link to the the image node + */ +function image_views_handler_image_img_link($fieldinfo, $fielddata, $value, $data) { + $node = node_load($data->nid); + return l(image_display($node, $fielddata['options']), "node/{$node->nid}", array(), NULL, NULL, FALSE, TRUE); +} + +/** + * Views - Generate a list of all the valid sizes that are available + */ +function image_views_handler_filter_image_size($op) { + foreach (_image_get_sizes() as $size) { + $a[$size['label']] = $size['label']; + } + $a['_original'] = 'original'; + return $a; +} + +/** * Verify the image module and toolkit settings. */ function _image_check_settings() {