1 image.module | image_effect_save($style_name, $effect) |
Save an image effect.
Parameters
$style_name: The image style this effect belongs to.
$effect: An image effect array.
Return value
An image effect array. In the case of a new effect, 'ieid' will be set.:
File
- core/
modules/ image/ image.module, line 1270 - Exposes global functionality for creating image styles.
Code
function image_effect_save($style_name, $effect) {
$config = config('image.style.' . $style_name);
$effects = $config->get('effects');
$filtered_effect = array(
'name' => $effect['name'],
'data' => isset($effect['data']) ? $effect['data'] : array(),
'weight' => isset($effect['weight']) ? $effect['weight'] : 0,
);
if (isset($effect['ieid'])) {
$effects[$effect['ieid']] = $filtered_effect;
}
else {
$effects[] = $filtered_effect;
end($effects);
$effect['ieid'] = key($effects);
}
$config->set('effects', $effects);
// Set default styles to overridden.
if ($config->get('module')) {
$config->set('overridden', TRUE);
}
$config->save();
$style = image_style_load($style_name);
image_style_flush($style);
return $effect;
}