image.inc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @file
  4. * Image module integration.
  5. */
  6. /**
  7. * Implements hook_custom_formatters_theme_alter() on behalf of image.module.
  8. */
  9. function image_custom_formatters_theme_alter(&$theme) {
  10. $theme['custom_formatters_image_styles'] = array(
  11. 'render element' => 'element',
  12. 'file' => 'includes/image.inc',
  13. );
  14. }
  15. /**
  16. * Implements hook_custom_formatters_element_info_alter() on behalf of
  17. * image.module.
  18. */
  19. function image_custom_formatters_element_info_alter(&$types) {
  20. $types['custom_formatters_image_styles'] = array(
  21. '#input' => TRUE,
  22. '#multiple' => FALSE,
  23. '#process' => array('form_process_select', 'ajax_process_form'),
  24. '#theme' => 'custom_formatters_image_styles',
  25. '#theme_wrappers' => array('form_element'),
  26. );
  27. }
  28. /**
  29. * Implements hook_custom_formatters_form_builder_types_alter() on behalf of
  30. * image.module.
  31. */
  32. function image_custom_formatters_form_builder_types_alter(&$fields) {
  33. $fields['image_styles'] = array(
  34. 'title' => t('Image styles'),
  35. 'properties' => array(
  36. 'title',
  37. 'description',
  38. 'default_value',
  39. 'required',
  40. 'key',
  41. ),
  42. 'default' => array(
  43. '#title' => t('New styles selector'),
  44. '#type' => 'custom_formatters_image_styles',
  45. '#multiple_toggle' => TRUE,
  46. ),
  47. );
  48. }
  49. /**
  50. * Theme callback for Custom Formatters Image Styles element.
  51. */
  52. function theme_custom_formatters_image_styles($variables) {
  53. $element = $variables['element'];
  54. $element['#options'] = image_style_options();
  55. element_set_attributes($element, array('id', 'name', 'size'));
  56. _form_set_class($element, array('form-select'));
  57. return '<select' . drupal_attributes($element['#attributes']) . '>' . form_select_options($element) . '</select>';
  58. }