styles.api.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @file
  4. * Hooks available for modules to implement Styles functionality.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Define information about style containers provided by a module.
  12. *
  13. * This hook enables modules to define style containers provided by this module.
  14. *
  15. * @return
  16. * An array of available style containers.Each container is defined as an
  17. * array keyed by the field type, each containing an associative array keyed
  18. * on a machine-readable style container name, with the following items:
  19. * - "label": The human-readable name of the effect.
  20. * - "data": An array of data that each container might require.
  21. * - "preview theme": (optional) A theme function to call when previewing
  22. * a style during administration.
  23. * - "help": (optional) A brief description of the style container that will
  24. * be displayed to the administrator when configuring styles.
  25. */
  26. function hook_styles_containers() {
  27. return array(
  28. 'media' => array(
  29. 'image' => array(
  30. 'label' => t('Image Styles'),
  31. 'data' => array(
  32. 'streams' => array(
  33. 'public://',
  34. 'private://',
  35. ),
  36. 'mimetypes' => array(
  37. 'image/png',
  38. 'image/gif',
  39. 'image/jpeg',
  40. ),
  41. ),
  42. 'preview theme' => 'media_styles_image_style_preview',
  43. 'help' => t('Image Styles will transform images to your choosing, such as by scaling and cropping. You can !manage.', array('!manage' => l(t('manage your image styles here'), 'admin/config/image/image-styles'))),
  44. ),
  45. ),
  46. );
  47. }
  48. function hook_styles_styles() {
  49. $styles = array();
  50. foreach (image_styles() as $style_name => $style) {
  51. $styles[$style_name] = $style;
  52. }
  53. return array(
  54. 'media' => array(
  55. 'image' => $styles,
  56. ),
  57. );
  58. }