Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
660165cc
Commit
660165cc
authored
Mar 31, 2014
by
webchick
Browse files
Issue
#2226171
by LinL, valthebald: Preview in Create Article gives error.
parent
5efa7d55
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/modules/image/lib/Drupal/image/Plugin/Field/FieldFormatter/ImageFormatter.php
View file @
660165cc
...
...
@@ -102,9 +102,11 @@ public function viewElements(FieldItemListInterface $items) {
// Check if the formatter involves a link.
if
(
$image_link_setting
==
'content'
)
{
$entity
=
$items
->
getEntity
();
// @todo Remove when theme_image_formatter() has support for route name.
$uri
[
'path'
]
=
$entity
->
getSystemPath
();
$uri
[
'options'
]
=
$entity
->
urlInfo
()
->
getOptions
();
if
(
!
$entity
->
isNew
())
{
// @todo Remove when theme_image_formatter() has support for route name.
$uri
[
'path'
]
=
$entity
->
getSystemPath
();
$uri
[
'options'
]
=
$entity
->
urlInfo
()
->
getOptions
();
}
}
elseif
(
$image_link_setting
==
'file'
)
{
$link_file
=
TRUE
;
...
...
core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
View file @
660165cc
...
...
@@ -54,6 +54,11 @@ function _testImageFieldFormatters($scheme) {
// Create a new node with an image attached.
$test_image
=
current
(
$this
->
drupalGetTestFiles
(
'image'
));
// Ensure that preview works.
$this
->
previewNodeImage
(
$test_image
,
$field_name
,
'article'
);
// Save node.
$nid
=
$this
->
uploadNodeImage
(
$test_image
,
$field_name
,
'article'
);
$node
=
node_load
(
$nid
,
TRUE
);
...
...
core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
View file @
660165cc
...
...
@@ -98,6 +98,24 @@ function createImageField($name, $type_name, $field_settings = array(), $instanc
}
/**
* Preview an image in a node.
*
* @param \Drupal\Core\Image\ImageInterface $image
* A file object representing the image to upload.
* @param string $field_name
* Name of the image field the image should be attached to.
* @param string $type
* The type of node to create.
*/
function
previewNodeImage
(
$image
,
$field_name
,
$type
)
{
$edit
=
array
(
'title[0][value]'
=>
$this
->
randomName
(),
);
$edit
[
'files['
.
$field_name
.
'_0]'
]
=
drupal_realpath
(
$image
->
uri
);
$this
->
drupalPostForm
(
'node/add/'
.
$type
,
$edit
,
t
(
'Preview'
));
}
/**
* Upload an image to a node.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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