Commit 3c7a609b authored by catch's avatar catch

Issue #1262592 by jmarkel, pingers, marcingy: Fixed numeric names fail image creation.

parent 169a8c12
......@@ -583,7 +583,10 @@ function image_style_options($include_empty = TRUE) {
if ($include_empty && !empty($styles)) {
$options[''] = t('<none>');
}
$options = array_merge($options, drupal_map_assoc(array_keys($styles)));
// Use the array concatenation operator '+' here instead of array_merge(),
// because the latter loses the datatype of the array keys, turning
// associative string keys into numeric ones without warning.
$options = $options + drupal_map_assoc(array_keys($styles));
if (empty($options)) {
$options[''] = t('No defined styles');
}
......
......@@ -367,6 +367,21 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
return count(file_scan_directory('public://styles/' . $style['name'], '/.*/'));
}
/**
* Test creating an image style with a numeric name and ensuring it can be
* applied to an image.
*/
function testNumericStyleName() {
$style_name = rand();
$edit = array(
'name' => $style_name,
);
$this->drupalPost('admin/config/media/image-styles/add', $edit, t('Create new style'));
$this->assertRaw(t('Style %name was created.', array('%name' => $style_name)), t('Image style successfully created.'));
$options = image_style_options();
$this->assertTrue(array_key_exists($style_name, $options), t('Array key %key exists.', array('%key' => $style_name)));
}
/**
* General test to add a style, add/remove/edit effects to it, then delete it.
*/
......
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