View source
<?php
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;
}
function image_views_handler_image_img($fieldinfo, $fielddata, $value, $data) {
$node = node_load($data->nid);
return image_display($node, $fielddata['options']);
}
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);
}
function image_views_handler_filter_image_size($op) {
foreach (_image_get_sizes() as $key => $size) {
$a[$key] = $size['label'];
}
return $a;
}