From c281ef5a38e1aca20f42013b734ad449361d9e9a Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 18 Aug 2014 18:08:20 +0100
Subject: [PATCH] Issue #2322377 by slashrsm | roald.umandal: Fixed No
 validation for default image.

---
 core/modules/image/src/Plugin/Field/FieldType/ImageItem.php  | 1 +
 core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
index a56f70162185..0cbb89a39e70 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 @@ protected function defaultImageForm(array &$element, array $settings) {
       '#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 d0fabfa00541..38fc1425ccd2 100644
--- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
@@ -278,6 +278,10 @@ public function testDefaultImages() {
         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.');
   }
 
   /**
-- 
GitLab