1 image_example.module image_example_image_styles_alter(&$styles)

Implements hook_image_styles_alter().

Allows your module to modify, add, or remove image styles provided by other modules. The best use of this hook is to modify default styles that have not been overridden by the user. Altering styles that have been overridden by the user could have an adverse effect on the user experience. If you add an effect to a style through this hook and the user attempts to remove the effect it will immediately be re-applied.

Related topics

File

modules/examples/image_example/image_example.module, line 138
Hooks implementations for the Image Example module.

Code

function image_example_image_styles_alter(&$styles) {
  // The $styles parameter is an array of image style arrays keyed by style
  // name. You can check to see if a style has been overridden by checking the
  // $styles['stylename']['storage'] property.
  // Verify that the effect has not been overridden.
  if ($styles['thumbnail']['storage'] == IMAGE_STORAGE_DEFAULT) {
    // Add an additional colorize effect to the system provided thumbnail
    // effect.
    $styles['thumbnail']['effects'][] = array(
      'label' => t('Colorize #FFFF66'),
      'name' => 'image_example_colorize',
      'effect callback' => 'image_example_colorize_effect',
      'data' => array(
        'color' => '#FFFF66',
      ),
      'weight' => 1,
    );
  }
}