function image_views_data in Image 6
Same name and namespace in other branches
- 7 views/image.views.inc \image_views_data()
Implementation of hook_views_data().
File
- views/
image.views.inc, line 11 - Views integration for Image module.
Code
function image_views_data() {
$data = array();
/**
* {image} table, using {node} as base table.
*
* This is needed for the image_file alias to work. Possibly a bug in views?
* @see http://drupal.org/node/425334
*/
$data['image']['table']['group'] = t('Image');
$data['image']['table']['join'] = array(
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
),
'files' => array(
'left_field' => 'fid',
'field' => 'fid',
),
);
/**
* {image} table alias, using {files} as base table.
*/
$data['image_file']['table']['group'] = t('Image');
$data['image_file']['table']['join'] = array(
'files' => array(
'table' => 'image',
'left_field' => 'fid',
'field' => 'fid',
),
);
// The preset size of the image.
$data['image_file']['image_size'] = array(
'title' => t('Image preset size'),
'help' => t('The preset image size of an image, e.g. <em>Original</em>, <em>Thumbnail</em>, etc.'),
'field' => array(
'handler' => 'image_handler_field_image_size',
'click sortable' => TRUE,
),
'argument' => array(
'handler' => 'image_handler_argument_image_size',
'parent' => 'views_handler_argument_string',
),
'filter' => array(
'handler' => 'image_handler_filter_image_size',
),
);
// Relationship to the node base.
// Allows us to go {files} --> {image} --> {node}.
$data['image_file']['nid'] = array(
'relationship' => array(
'title' => t('Node'),
'label' => t('Image node'),
'help' => t('A relationship to gain access to the corresponding node of an image file uploaded via Image module.'),
'base' => 'node',
'field' => 'nid',
'relationship table' => 'image',
'relationship field' => 'nid',
'base field' => 'nid',
'handler' => 'views_handler_relationship',
),
);
/**
* {image} table alias, using {node} as base table.
*/
$data['image_node']['table']['group'] = t('Image');
$data['image_node']['table']['join'] = array(
'node' => array(
'table' => 'image',
'left_field' => 'nid',
'field' => 'nid',
),
);
// Relationship to the files base.
// Allows us to go {node} --> {image} --> {files}.
$data['image_node']['nid'] = array(
'relationship' => array(
'title' => t('File'),
'label' => t('Image file'),
'help' => t('A relationship to gain access to the corresponding file(s) of an image node.'),
'base' => 'files',
'field' => 'fid',
'relationship table' => 'image',
'relationship field' => 'fid',
'base field' => 'fid',
'handler' => 'image_handler_relationship_node_image_file',
),
);
return $data;
}