You are here

views.inc in Image 5

Same filename and directory in other branches
  1. 5.2 views.inc

File

views.inc
View source
<?php

/**
 * 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;
}

/**
 * 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 $key => $size) {
    $a[$key] = $size['label'];
  }
  return $a;
}

Functions

Namesort descending Description
image_views_handler_filter_image_size Views - Generate a list of all the valid sizes that are available
image_views_handler_image_img Views handler for displaying the image.
image_views_handler_image_img_link Views handler for displaying the image in a link to the the image node
image_views_tables Implementation of hook_views_tables()