Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
c281ef5a
Commit
c281ef5a
authored
Aug 18, 2014
by
Alex Pott
Browse files
Issue
#2322377
by slashrsm | roald.umandal: Fixed No validation for default image.
parent
0aaa1c80
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
View file @
c281ef5a
...
...
@@ -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'
,
...
...
core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
View file @
c281ef5a
...
...
@@ -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.'
);
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment