- Issue created by @safetypin
I'd like to move an image field rendering from the node content to a region on the page.
I currently build a render array for a regular image field like this:
if (isset($fields['field_image'])) {
$field_view = $fields['field_image']->view(['label' => 'hidden']);
$field_view['0']['#image_style'] = 'large';
$field_view['#view_mode'] = 'full';
$variables['page']['lead'][] = $field_view;
}
This works to render the image inside the "lead" region of the page.
My attempts (so far) to replicate this using a responsive image field that is configured to render as a responsive image with the image_replace module functionality results in just the original image rendered in the lead region, lacking the setsrc
tag:
if (isset($fields['field_responsive_lead_image'])) {
$field_view = $fields['field_responsive_lead_image']->view(['label' => 'hidden']);
$field_view['#view_mode'] = 'responsive_image';
$field_view['#image_style'] = 'lead_image';
$variables['page']['lead'][] = $field_view;
}
What array elements do I need to configure (presumably instead of [or in addition to] $field_view['#image_style'] = 'lead_image'
) to trigger the image_replace module to step in and render a responsive image?
Active
2.0
Code