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

ISTWCMS-2448 Fix variables sources for options block

parent c9a10865
No related branches found
No related tags found
No related merge requests found
......@@ -124,8 +124,14 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) {
//Get value from field_uw_options field;
$field_values = $variables['paragraph']->get('field_uw_options')->getValue();
// Get the number of field_values.
$total_count = count($field_values);
// Define a counter.
$i = 0;
// Process field_uw_options field which includes multiple entities.
foreach ($field_values as $field_value) {
// Get paragraph entity of field_uw_options field from the target_id.
......@@ -168,7 +174,12 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) {
// Add all variables to an array.
$options[$i]['img_element'] = $variables['img_element']['#uri'];
$options[$i]['sources'] = $variables['sources'][$i];
// Set sources because each entity has 5 responsive sources.
if ($i < $total_count){
$options[$i]['sources'] = (array_slice($variables['sources'], $i*5));
}
$options[$i]['alt'] = $variables['alt'];
$options[$i]['url'] = $variables['uri'];
$options[$i]['responsive_image_style_id'] = $variables['responsive_image_style_id'];
......@@ -178,6 +189,7 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) {
$i++;
}
$variables['options'] = $options;
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