diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index ecb72d8..896f4b5 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -376,6 +376,12 @@ function image_effect_form_submit($form, &$form_state) { 'data' => $form_state['values']['data'], 'weight' => $form_state['values']['weight'], ); + + // Are we editing an exiting style. + if (!empty($form_state['image_effect']['ieid'])) { + $effect['ieid'] = $form_state['image_effect']['ieid']; + } + image_effect_save($form_state['image_style']['name'], $effect); drupal_set_message(t('The image effect was successfully applied.')); $form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $form_state['image_style']['name']; diff --git a/core/modules/image/image.test b/core/modules/image/image.test index 2c422a7..5f07bec 100644 --- a/core/modules/image/image.test +++ b/core/modules/image/image.test @@ -565,6 +565,23 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase { $this->drupalGet('node/' . $nid); $this->assertRaw(image_style_url('thumbnail', $node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['uri']), t('Image displayed using style replacement style.')); } + + /** + * Verify that editing an image effect does not cause it to duplicate. + */ + function testEditEffect() { + $this->drupalGet('admin/config/media/image-styles/add'); + $this->drupalPost(NULL, array('name' => 'test_style_effect_edit'), t('Create new style')); + $this->drupalPost(NULL, array('new' => 'image_scale_and_crop'), t('Add')); + $this->drupalPost(NULL, array('data[width]' => '300', 'data[height]' => '200'), t('Add effect')); + $this->assertText(t('Scale and crop 300x200')); + // There should normally be only the one edit link on this page initially. + $this->clickLink(t('edit')); + $this->drupalPost(NULL, array('data[width]' => '360', 'data[height]' => '240'), t('Update effect')); + $this->assertText(t('Scale and crop 360x240')); + // Check the previous effect is not also retained on this style after editing. + $this->assertNoText(t('Scale and crop 300x200')); + } } /**