function image_example_image_styles_alter in Examples for Developers 7
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 overriden by the user. Altering styles that have been overriden by the user could have an adverse affect 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 immediatly be re-applied.
Related topics
File
- image_example/
image_example.module, line 202 - Module file for image_example
Code
function image_example_image_styles_alter(&$styles) {
// The $styles paramater is an array of image style arrays keyed by style
// name. You can check to see if a style has been overriden by checking the
// $styles['stylename']['storage'] property.
// Verify that the effect has not been overriden.
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,
);
}
}