colorbox.api.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * @file
  4. * API documentation for the colorbox module.
  5. */
  6. /**
  7. * Allows to override Colorbox settings and style.
  8. *
  9. * Implements hook_colorbox_settings_alter().
  10. *
  11. * @param array $settings
  12. * An associative array of Colorbox settings. See the
  13. * @link http://colorpowered.com/colorbox/ Colorbox documentation @endlink
  14. * for the full list of supported parameters.
  15. * @param string $style
  16. * The name of the active style plugin. If $style is 'none', no Colorbox
  17. * theme will be loaded.
  18. */
  19. function hook_colorbox_settings_alter(&$settings, &$style) {
  20. // Disable automatic downscaling of images to maxWidth/maxHeight size.
  21. $settings['scalePhotos'] = FALSE;
  22. // Use custom style plugin specifically for node/123.
  23. if ($_GET['q'] == 'node/123') {
  24. $style = 'mystyle';
  25. }
  26. }
  27. /**
  28. * Allows to override activation of Colorbox for the current URL.
  29. *
  30. * @param bool $active
  31. * A boolean indicating whether colorbox should be active for the current
  32. * URL or not.
  33. */
  34. function hook_colorbox_active_alter(&$active) {
  35. $path = drupal_get_path_alias($_GET['q']);
  36. if (drupal_match_path($path, 'admin/config/colorbox_test')) {
  37. // Enable colorbox for this URL.
  38. $active = TRUE;
  39. }
  40. }