Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
uw_fdsu_theme_resp
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_fdsu_theme_resp
Commits
622d2e38
Commit
622d2e38
authored
6 years ago
by
Liam Morland
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-2452: Create _uw_fdsu_theme_resp_get_image_info()
parent
86963b36
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uw_fdsu_theme_resp.theme
+23
-0
23 additions, 0 deletions
uw_fdsu_theme_resp.theme
with
23 additions
and
0 deletions
uw_fdsu_theme_resp.theme
+
23
−
0
View file @
622d2e38
...
...
@@ -319,3 +319,26 @@ function _uw_fdsu_theme_resp_add_responsive_image_variables(array &$variables, $
return
$new_sources
;
}
}
/**
* Get image properties from an image field.
*
* @param object $field
* The image field.
*
* @return array|null
* An array of image properties or NULL if $field does not contain the
* required information.
*/
function
_uw_fdsu_theme_resp_get_image_info
(
Drupal
\file\Plugin\Field\FieldType\FileFieldItemList
$field
)
{
// If there is an image, process it.
if
(
$img_entity
=
$field
->
first
())
{
// If we can load a file, grab the info about the file.
if
(
$file_entity
=
$img_entity
->
get
(
'entity'
)
->
getTarget
())
{
return
[
'src'
=>
file_create_url
(
$file_entity
->
get
(
'uri'
)
->
getString
()),
'alt'
=>
$img_entity
->
get
(
'alt'
)
->
getString
(),
];
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment