You are here

image.inc in Custom Formatters 7.2

Image module integration.

File

includes/image.inc
View source
<?php

/**
 * @file
 * Image module integration.
 */

/**
 * Implements hook_custom_formatters_theme_alter().
 */
function image_custom_formatters_theme_alter(&$theme) {
  $theme['custom_formatters_image_styles'] = array(
    'render element' => 'element',
    'file' => 'includes/image.inc',
  );
}

/**
 * Implements hook_custom_formatters_element_info_alter().
 */
function image_custom_formatters_element_info_alter(&$types) {
  $types['custom_formatters_image_styles'] = array(
    '#input' => TRUE,
    '#multiple' => FALSE,
    '#process' => array(
      'form_process_select',
      'ajax_process_form',
    ),
    '#theme' => 'custom_formatters_image_styles',
    '#theme_wrappers' => array(
      'form_element',
    ),
  );
}

/**
 * Implements hook_custom_formatters_form_builder_types_alter().
 */
function image_custom_formatters_form_builder_types_alter(&$fields) {
  $fields['image_styles'] = array(
    'title' => t('Image styles'),
    'properties' => array(
      'title',
      'description',
      'default_value',
      'required',
      'key',
    ),
    'default' => array(
      '#title' => t('New styles selector'),
      '#type' => 'custom_formatters_image_styles',
      '#multiple_toggle' => TRUE,
    ),
  );
}

/**
 * Theme callback for Custom Formatters Image Styles element.
 *
 * @param array $variables
 *   The theme varibles array.
 *
 * @return string
 *   The rendered image styles element.
 */
function theme_custom_formatters_image_styles($variables) {
  $element = $variables['element'];
  $element['#options'] = image_style_options();
  element_set_attributes($element, array(
    'id',
    'name',
    'size',
  ));
  _form_set_class($element, array(
    'form-select',
  ));
  return '<select' . drupal_attributes($element['#attributes']) . '>' . form_select_options($element) . '</select>';
}

Functions

Namesort descending Description
image_custom_formatters_element_info_alter Implements hook_custom_formatters_element_info_alter().
image_custom_formatters_form_builder_types_alter Implements hook_custom_formatters_form_builder_types_alter().
image_custom_formatters_theme_alter Implements hook_custom_formatters_theme_alter().
theme_custom_formatters_image_styles Theme callback for Custom Formatters Image Styles element.