home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (image_handler_relationship_node_image_file.inc)

This example Drupal source code file (image_handler_relationship_node_image_file.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, form, function, if, image_size_options, join, multiple, no, php, sizes, string, the, will, you

The image_handler_relationship_node_image_file.inc Drupal example source code

// $Id: image_handler_relationship_node_image_file.inc,v 1.1 2009/05/01 22:29:47 sun Exp $

 * @file
 * Views relationship handler for image size filter.

class image_handler_relationship_node_image_file extends views_handler_relationship {

  function option_definition() {
    $options = parent::option_definition();
    $options['image_size'] = array('default' => IMAGE_THUMBNAIL);
    return $options;

  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);

    $image_size_options = array();
    foreach (image_get_sizes() as $key => $size) {
      $image_size_options[$key] = $size['label'];

    $form['image_size'] = array(
      '#type' => 'select',
      '#title' => t('Image sizes'),
      '#options' => $image_size_options,
      '#default_value' => $this->options['image_size'],
      '#multiple' => TRUE,
      '#description' => t('Which image sizes to join on. You can select none (to include all sizes), one, or multiple; Every size will introduce a new row. Example: If the result are 5 image nodes and you selected 2 sizes; The result will be 10 rows. There is no fallback; if a size does not exist (because the original is smaller) then no data will be obtained.'),

  function ensure_my_table() {
    if (!isset($this->table_alias)) {
      $join = $this->get_join();

      // Adjust the join for the selected image size.
      if (!empty($this->options['image_size'])) {
        $join->extra[] = array(
          'field' => 'image_size',
          'value' => $this->options['image_size'],
      $this->table_alias = $this->query->add_table($this->table, $this->relationship, $join);
    return $this->table_alias;

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal image_handler_relationship_node_image_file.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.