summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngie Byron2010-04-22 21:43:59 (GMT)
committerAngie Byron2010-04-22 21:43:59 (GMT)
commite2e096985fa42336c196facdf087d6e754e6b2cc (patch)
tree1df07420effa50173282341cd8401b0bebf760e2
parentcca6d06c01e377975e8625b6743d069e08b38684 (diff)
#746500 by eojthebrave: Fixed Overriding default image styles does not work with more than one effect and has potential to overwrite existing effects.
-rw-r--r--modules/image/image.admin.inc39
-rw-r--r--modules/image/image.module7
-rw-r--r--modules/image/image.test10
3 files changed, 35 insertions, 21 deletions
diff --git a/modules/image/image.admin.inc b/modules/image/image.admin.inc
index 8ef98a8..e239384 100644
--- a/modules/image/image.admin.inc
+++ b/modules/image/image.admin.inc
@@ -83,31 +83,36 @@ function image_style_form($form, &$form_state, $style) {
$form['effects'] = array(
'#theme' => 'image_style_effects',
);
- foreach ($style['effects'] as $ieid => $effect) {
- $form['effects'][$ieid]['#weight'] = isset($form_state['input']['effects']) ? $form_state['input']['effects'][$ieid]['weight'] : NULL;
- $form['effects'][$ieid]['label'] = array(
+ foreach ($style['effects'] as $key => $effect) {
+ $form['effects'][$key]['#weight'] = isset($form_state['input']['effects']) ? $form_state['input']['effects'][$key]['weight'] : NULL;
+ $form['effects'][$key]['label'] = array(
'#markup' => $effect['label'],
);
- $form['effects'][$ieid]['summary'] = array(
+ $form['effects'][$key]['summary'] = array(
'#markup' => isset($effect['summary theme']) ? theme($effect['summary theme'], array('data' => $effect['data'])) : '',
);
- $form['effects'][$ieid]['weight'] = array(
+ $form['effects'][$key]['weight'] = array(
'#type' => 'weight',
'#default_value' => $effect['weight'],
'#access' => $editable,
);
- $form['effects'][$ieid]['configure'] = array(
- '#type' => 'link',
- '#title' => t('edit'),
- '#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'],
- '#access' => $editable && isset($effect['form callback']),
- );
- $form['effects'][$ieid]['remove'] = array(
- '#type' => 'link',
- '#title' => t('delete'),
- '#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'] . '/delete',
- '#access' => $editable,
- );
+
+ // Only attempt to display these fields for editable styles as the 'ieid'
+ // key is not set for styles defined in code.
+ if ($editable) {
+ $form['effects'][$key]['configure'] = array(
+ '#type' => 'link',
+ '#title' => t('edit'),
+ '#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'],
+ '#access' => $editable && isset($effect['form callback']),
+ );
+ $form['effects'][$key]['remove'] = array(
+ '#type' => 'link',
+ '#title' => t('delete'),
+ '#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'] . '/delete',
+ '#access' => $editable,
+ );
+ }
}
// Build the new image effect addition form and add it to the effect list.
diff --git a/modules/image/image.module b/modules/image/image.module
index 42641f8..f9322bd 100644
--- a/modules/image/image.module
+++ b/modules/image/image.module
@@ -435,11 +435,10 @@ function image_styles() {
$style['name'] = $style_name;
$style['module'] = $module;
$style['storage'] = IMAGE_STORAGE_DEFAULT;
- foreach ($style['effects'] as $ieid => $effect) {
+ foreach ($style['effects'] as $key => $effect) {
$definition = image_effect_definition_load($effect['name']);
$effect = array_merge($definition, $effect);
- $effect['ieid'] = $ieid;
- $style['effects'][$ieid] = $effect;
+ $style['effects'][$key] = $effect;
}
$styles[$style_name] = $style;
}
@@ -834,7 +833,7 @@ function image_default_style_save($style) {
$effects = array();
foreach ($style['effects'] as $effect) {
$effect['isid'] = $style['isid'];
- image_effect_save($effect);
+ $effect = image_effect_save($effect);
$effects[$effect['ieid']] = $effect;
}
$style['effects'] = $effects;
diff --git a/modules/image/image.test b/modules/image/image.test
index 114cd59..fded567 100644
--- a/modules/image/image.test
+++ b/modules/image/image.test
@@ -536,6 +536,11 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
$image_path = $this->createSampleImage($style);
$this->assertEqual($this->getImageCount($style), 1, t('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
+ // Verify that effects attached to a default style do not have an ieid key.
+ foreach ($style['effects'] as $effect) {
+ $this->assertFalse(isset($effect['ieid']), t('The %effect effect does not have an ieid.', array('%effect' => $effect['name'])));
+ }
+
// Override the default.
$this->drupalPost($edit_path, array(), t('Override defaults'));
$this->assertRaw(t('The %style style has been overridden, allowing you to change its settings.', array('%style' => $style_name)), t('Default image style may be overridden.'));
@@ -545,6 +550,11 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
drupal_static_reset('image_styles');
$style = image_style_load($style_name);
+ // Verify that effects attached to the style have an ieid now.
+ foreach ($style['effects'] as $effect) {
+ $this->assertTrue(isset($effect['ieid']), t('The %effect effect has an ieid.', array('%effect' => $effect['name'])));
+ }
+
// The style should now have 2 effect, the original scale provided by core
// and the desaturate effect we added in the override.
$effects = array_values($style['effects']);