Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
222
Merge Requests
222
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
660165cc
Commit
660165cc
authored
Mar 31, 2014
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2226171
by LinL, valthebald: Preview in Create Article gives error.
parent
5efa7d55
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
core/modules/image/lib/Drupal/image/Plugin/Field/FieldFormatter/ImageFormatter.php
...upal/image/Plugin/Field/FieldFormatter/ImageFormatter.php
+5
-3
core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
...es/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
+5
-0
core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
...dules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
+18
-0
No files found.
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