function image_effect_save

Saves an image effect.

Parameters

ImageStyle $style: The image style this effect belongs to.

array $effect: An image effect array. Passed by reference.

Return value

array The saved image effect array. The 'ieid' key will be set for the effect.

3 calls to image_effect_save()
ImageDimensionsTest::testImageDimensions in drupal/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php
Test styled image dimensions cumulatively.
image_effect_form_submit in drupal/core/modules/image/image.admin.inc
Submit handler for updating an image effect.
image_style_form_add_submit in drupal/core/modules/image/image.admin.inc
Submit handler for adding a new image effect to an image style.

File

drupal/core/modules/image/image.module, line 942
Exposes global functionality for creating image styles.

Code

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);
}