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

Drupal example source code file (views_handler_field_file_filemime.inc)

This example Drupal source code file (views_handler_field_file_filemime.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, data, empty, fake_file, form, form_state, function, mime, options, php, return, the, type, values

The views_handler_field_file_filemime.inc Drupal example source code

// $Id: views_handler_field_file_filemime.inc,v 2010/10/06 17:47:37 dereine Exp $

 * Field handler to add rendering MIME type images as an option on the filemime field.
class views_handler_field_file_filemime extends views_handler_field_file {
  function option_definition() {
    $options = parent::option_definition();
    $options['filemime_image'] = array('default' => FALSE);
    return $options;

  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['filemime_image'] = array(
      '#title' => t('Display an image representing the MIME type instead of the MIME text.'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['filemime_image']),

  function render($values) {
    $data = $values->{$this->field_alias};
    if (!empty($this->options['filemime_image']) && $data !== NULL && $data !== '') {
      $fake_file = (object) array('filemime' => $data);
      $data = theme('file_icon', array('file' => $fake_file));

    return $this->render_link($data, $values);

Other Drupal examples (source code examples)

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