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
02708195
Commit
02708195
authored
6 years ago
by
l26yan
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-2448 Use responsive images
parent
88858661
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
templates/paragraphs/paragraph--uw-para-options-block.html.twig
+5
-3
5 additions, 3 deletions
...tes/paragraphs/paragraph--uw-para-options-block.html.twig
uw_fdsu_theme_resp.theme
+27
-7
27 additions, 7 deletions
uw_fdsu_theme_resp.theme
with
32 additions
and
10 deletions
templates/paragraphs/paragraph--uw-para-options-block.html.twig
+
5
−
3
View file @
02708195
...
@@ -6,8 +6,6 @@
...
@@ -6,8 +6,6 @@
link_uri
:
item
[
'#paragraph'
]
.
field_uw_option_link.value
[
0
][
'uri'
],
link_uri
:
item
[
'#paragraph'
]
.
field_uw_option_link.value
[
0
][
'uri'
],
link_title
:
item
[
'#paragraph'
]
.
field_uw_option_link.value
[
0
][
'title'
],
link_title
:
item
[
'#paragraph'
]
.
field_uw_option_link.value
[
0
][
'title'
],
link_colouring
:
item
[
'#paragraph'
]
.
field_uw_option_colouring.value
,
link_colouring
:
item
[
'#paragraph'
]
.
field_uw_option_colouring.value
,
img_src
:
file_url
(
item
[
'#paragraph'
]
.
field_uw_option_image.entity.uri.value
),
img_alt
:
item
[
'#paragraph'
]
.
field_uw_option_image.alt
}
])
}
])
%}
%}
{%
endfor
%}
{%
endfor
%}
...
@@ -15,5 +13,9 @@
...
@@ -15,5 +13,9 @@
{%
include
'@organisms/single-page/options-block/options-block.twig'
with
{
{%
include
'@organisms/single-page/options-block/options-block.twig'
with
{
'display_title'
:
display_title
,
'display_title'
:
display_title
,
'title'
:
content.field_uw_block_title
|
field_value
,
'title'
:
content.field_uw_block_title
|
field_value
,
'options'
:
options
'options'
:
options
,
'sources'
:
sources
,
'output_image_tag'
:
output_image_tag
,
'img_element'
:
img_element
[
'#uri'
],
'alt'
:
alt
}
%}
}
%}
This diff is collapsed.
Click to expand it.
uw_fdsu_theme_resp.theme
+
27
−
7
View file @
02708195
...
@@ -122,16 +122,36 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) {
...
@@ -122,16 +122,36 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) {
$variables
[
'display_title'
]
=
"Off"
;
$variables
[
'display_title'
]
=
"Off"
;
}
}
//Get value from field_uw_options field;
$field_values
=
$variables
[
'paragraph'
]
->
get
(
'field_uw_options'
)
->
getValue
();
//$field = $variables['paragraph']->get('field_uw_options')->first();
foreach
(
$field_values
as
$field_value
)
{
//vardumper($field);
//$a = $variables['paragraph']->get('field_uw_options');
//vardumper($a);
//$options[0]['img_src'] = 'img src';
// Get paragraph entity of field_uw_options field from the target_id.
//$options[0]['img_src'] = 'img src';
$p
=
\Drupal\paragraphs\Entity\Paragraph
::
load
(
$field_value
[
'target_id'
]);
break
;
// Get the field entity from the paragraph.
$field
=
$p
->
field_uw_option_image
->
first
();
// Set the alt tag from the field entity.
$variables
[
'alt'
]
=
$field
->
get
(
'alt'
)
->
getValue
();
// Set the file entity based on the field name.
$file
=
$field
->
entity
;
// If there is a file present, set responsive image variables.
if
(
$file
)
{
// Set uri and image style id.
$variables
[
'uri'
]
=
$file
->
getFileUri
();
$variables
[
'responsive_image_style_id'
]
=
'uw_resp_is_sph_header_image'
;
// Call template function from responsive image core module.
// It sets variables for srcset, media, type and img_element
// for the responsive image style.
template_preprocess_responsive_image
(
$variables
);
}
}
break
;
}
}
}
}
...
...
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