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

Drupal example source code file (image_handler_field_image_size.inc)

This example Drupal source code file (image_handler_field_image_size.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, check_plain, extends, function, image_get_sizes, image_size, isset, options, php, render, return, values, var, view

The image_handler_field_image_size.inc Drupal example source code

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

 * @file
 * Views handler for image size field.

 * Render the human-readable name of a given image size.
 * @return
 *   The human-readable name or an empty string for an invalid image size.
class image_handler_field_image_size extends views_handler_field {
  var $image_sizes = array();

  function init(&$view, $options) {
    parent::init($view, $options);
    $this->image_sizes = image_get_sizes();

  function render($values) {
    $image_size = $values->{$this->field_alias};

    if (!empty($image_size) && isset($this->image_sizes[$image_size])) {
      return check_plain($this->image_sizes[$image_size]['label']);

    return '';

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal image_handler_field_image_size.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.