Saves an image effect.
ImageStyle $style: The image style this effect belongs to.
array $effect: An image effect array. Passed by reference.
array The saved image effect array. The 'ieid' key will be set for the effect.
function image_effect_save($style, &$effect) {
// Remove all values that are not properties of an image effect.
// @todo Convert image effects into plugins.
$effect = array_intersect_key($effect, array_flip(array(
'ieid',
'module',
'name',
'data',
'weight',
)));
// Generate a unique image effect ID for a new effect.
if (empty($effect['ieid'])) {
$uuid = new Uuid();
$effect['ieid'] = $uuid
->generate();
}
$style->effects[$effect['ieid']] = $effect;
$style
->save();
// Flush all derivatives that exist for this style, so they are regenerated
// with the new or updated effect.
image_style_flush($style);
}