Commit c16a978c authored by Dries's avatar Dries

- Patch #1497088 by acrollet: Fixed Empty configuration values should return...

- Patch #1497088 by acrollet: Fixed Empty configuration values should return an empty string instead of an empty array.
parent 0de82eef
......@@ -38,6 +38,12 @@ public function __construct(DrupalConfigVerifiedStorageInterface $verified_stora
public function read() {
$active = (array) config_decode($this->_verifiedStorage->read());
foreach ($active as $key => $value) {
// If the setting is empty, return an empty string rather than an array.
// This is necessary because SimpleXML's default behavior is to return
// an empty array instead of a string.
if (is_array($value) && empty($value)) {
$value = '';
}
$this->set($key, $value);
}
}
......
......@@ -63,32 +63,34 @@ function image_style_form($form, &$form_state, $style) {
$form['effects'] = array(
'#theme' => 'image_style_effects',
);
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'][$key]['summary'] = array(
'#markup' => isset($effect['summary theme']) ? theme($effect['summary theme'], array('data' => $effect['data'])) : '',
);
$form['effects'][$key]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array('@title' => $effect['label'])),
'#title_display' => 'invisible',
'#default_value' => $effect['weight'],
);
if (!empty($style['effects'])) {
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'][$key]['summary'] = array(
'#markup' => isset($effect['summary theme']) ? theme($effect['summary theme'], array('data' => $effect['data'])) : '',
);
$form['effects'][$key]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array('@title' => $effect['label'])),
'#title_display' => 'invisible',
'#default_value' => $effect['weight'],
);
$form['effects'][$key]['configure'] = array(
'#type' => 'link',
'#title' => t('edit'),
'#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $key,
'#access' => isset($effect['form callback']),
);
$form['effects'][$key]['remove'] = array(
'#type' => 'link',
'#title' => t('delete'),
'#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $key . '/delete',
);
$form['effects'][$key]['configure'] = array(
'#type' => 'link',
'#title' => t('edit'),
'#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $key,
'#access' => isset($effect['form callback']),
);
$form['effects'][$key]['remove'] = array(
'#type' => 'link',
'#title' => t('delete'),
'#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $key . '/delete',
);
}
}
// Build the new image effect addition form and add it to the effect list.
......
......@@ -484,13 +484,15 @@ function image_style_load($name) {
return FALSE;
}
foreach ($style['effects'] as $ieid => $effect) {
$definition = image_effect_definition_load($effect['name']);
$effect = array_merge($definition, $effect);
$style['effects'][$ieid] = $effect;
if (!empty($style['effects'])) {
foreach ($style['effects'] as $ieid => $effect) {
$definition = image_effect_definition_load($effect['name']);
$effect = array_merge($definition, $effect);
$style['effects'][$ieid] = $effect;
}
// Sort effects by weight.
uasort($style['effects'], 'drupal_sort_weight');
}
// Sort effects by weight.
uasort($style['effects'], 'drupal_sort_weight');
return $style;
}
......@@ -698,8 +700,10 @@ function image_style_create_derivative($style, $source, $destination) {
return FALSE;
}
foreach ($style['effects'] as $effect) {
image_effect_apply($image, $effect);
if (!empty($style['effects'])) {
foreach ($style['effects'] as $effect) {
image_effect_apply($image, $effect);
}
}
if (!image_save($image, $destination)) {
......@@ -731,16 +735,18 @@ function image_style_transform_dimensions($style_name, array &$dimensions) {
return;
}
foreach ($style['effects'] as $effect) {
if (isset($effect['dimensions passthrough'])) {
continue;
}
if (!empty($style['effects'])) {
foreach ($style['effects'] as $effect) {
if (isset($effect['dimensions passthrough'])) {
continue;
}
if (isset($effect['dimensions callback'])) {
$effect['dimensions callback']($dimensions, $effect['data']);
}
else {
$dimensions['width'] = $dimensions['height'] = NULL;
if (isset($effect['dimensions callback'])) {
$effect['dimensions callback']($dimensions, $effect['data']);
}
else {
$dimensions['width'] = $dimensions['height'] = NULL;
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment