summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-08-18 17:08:20 (GMT)
committerAlex Pott2014-08-18 17:08:20 (GMT)
commitc281ef5a38e1aca20f42013b734ad449361d9e9a (patch)
treea8bd4b8061891f6d9e3f6e14685d2483d28ed4c9
parent0aaa1c80980cfd48d7ed5611334ae696e168c31c (diff)
Issue #2322377 by slashrsm | roald.umandal: Fixed No validation for default image.
-rw-r--r--core/modules/image/src/Plugin/Field/FieldType/ImageItem.php1
-rw-r--r--core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php4
2 files changed, 5 insertions, 0 deletions
diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
index a56f701..0cbb89a 100644
--- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
+++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
@@ -350,6 +350,7 @@ class ImageItem extends FileItem {
'#default_value' => empty($settings['default_image']['fid']) ? array() : array($settings['default_image']['fid']),
'#upload_location' => $settings['uri_scheme'] . '://default_images/',
'#element_validate' => array('file_managed_file_validate', array(get_class($this), 'validateDefaultImageForm')),
+ '#upload_validators' => $this->getUploadValidators(),
);
$element['default_image']['alt'] = array(
'#type' => 'textfield',
diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
index d0fabfa..38fc142 100644
--- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
@@ -278,6 +278,10 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
array('@fid' => $default_images['instance2']->id())
)
);
+
+ $non_image = $this->drupalGetTestFiles('text');
+ $this->drupalPostForm(NULL, array('files[instance_settings_default_image_fid]' => drupal_realpath($non_image[0]->uri)), t("Upload"));
+ $this->assertText(t('The specified file text-0.txt could not be uploaded. Only files with the following extensions are allowed: png gif jpg jpeg.'), 'Non-image file cannot be used as default image.');
}
/**