Skip to content
Snippets Groups Projects
Commit b092c360 authored by l26yan's avatar l26yan
Browse files

ISTWCMS-2448 Make drupal site display multiple images

parent e1ab6e0b
No related branches found
No related tags found
No related merge requests found
{% include '@organisms/single-page/options-block/options-block.twig' with { {% include '@organisms/single-page/options-block/options-block.twig' with {
'display_title': display_title, 'options': options
'title': content.field_uw_block_title|field_value,
'link_description': link_description,
'link_uri': link_uri,
'link_title': link_title,
'link_colouring': link_colouring,
'sources': sources,
'output_image_tag': output_image_tag,
'img_element': img_element['#uri'],
'alt': alt
}%} }%}
\ No newline at end of file
...@@ -128,12 +128,26 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) { ...@@ -128,12 +128,26 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) {
foreach ($field_values as $field_value) { foreach ($field_values as $field_value) {
// Get paragraph entity of field_uw_options field from the target_id. // Get paragraph entity of field_uw_options field from the target_id.
$p = \Drupal\paragraphs\Entity\Paragraph::load($field_value['target_id']); $p = \Drupal\paragraphs\Entity\Paragraph::load($field_value['target_id']);
// Get the field entity from the paragraph. // Get link description and add to the variable array.
$field = $p->field_uw_option_image->first(); $link_description = $p->field_uw_link_description->first()->getValue();
$options2[$i]['link_description'] = $link_description['value'];
// Get colouring value and add to the variable array.
$link_colouring = $p->field_uw_option_colouring->first()->getValue();
$options[$i]['link_colouring'] = $link_colouring['value'];
// Get link uri and title and add to the variable array.
$link = $p->field_uw_option_link->first()->getValue();
$options[$i]['link_url'] = $link['uri'];
$options[$i]['link_title'] = $link['title'];
// Get the field entity from the paragraph.
$field = $p->field_uw_option_image->first();
if (isset($field)) {
// Set the alt tag from the field entity. // Set the alt tag from the field entity.
$variables['alt'] = $field->get('alt')->getValue(); $variables['alt'] = $field->get('alt')->getValue();
...@@ -142,41 +156,28 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) { ...@@ -142,41 +156,28 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) {
// If there is a file present, set responsive image variables. // If there is a file present, set responsive image variables.
if ($file) { if ($file) {
// Set uri and image style id. // Set uri and image style id.
$variables['uri'] = $file->getFileUri(); $variables['uri'] = $file->getFileUri();
$variables['responsive_image_style_id'] = 'uw_resp_is_sph_header_image'; $variables['responsive_image_style_id'] = 'uw_resp_is_sph_header_image';
// Call template function from responsive image core module. // Call template function from responsive image core module.
// It sets variables for srcset, media, type and img_element // It sets variables for srcset, media, type and img_element
// for the responsive image style. // for the responsive image style.
template_preprocess_responsive_image($variables); template_preprocess_responsive_image($variables);
// Add all variables to an array. // Add all variables to an array.
$options2[$i]['alt'] = $variables['alt']; $options[$i]['img_element'] = $variables['img_element']['#uri'];
$options2[$i]['uri'] = $variables['uri']; $options[$i]['sources'] = $variables['sources'][$i];
$options2[$i]['responsive_image_style_id'] = $variables['responsive_image_style_id']; $options[$i]['alt'] = $variables['alt'];
$options2[$i]['sources'] = $variables['sources']; $options[$i]['url'] = $variables['uri'];
$options2[$i]['output_image_tag'] = $variables['output_image_tag']; $options[$i]['responsive_image_style_id'] = $variables['responsive_image_style_id'];
$options2[$i]['img_element'] = $variables['img_element']; //$options[$i]['output_image_tag'] = $variables['output_image_tag'];
} }
}
// Get colouring value and add to the variable array. $i++;
$link_colouring = $p->field_uw_option_colouring->first()->getValue();
$options2[$i]['link_colouring'] = $link_colouring['value'];
// Get link description and add to the variable array.
$link_description = $p->field_uw_link_description->first()->getValue();
$options2[$i]['link_description'] = $link_description['value'];
// Get link uri and title and add to the variable array.
$link = $p->field_uw_option_link->first()->getValue();
$options2[$i]['link_uri'] = $link['uri'];
$options2[$i]['link_title'] = $link['title'];
$i++;
} }
$variables['options'] = $options;
$variables['options2'] = $options2;
vardumper($options2);
break; break;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment