Skip to content
Snippets Groups Projects
Commit d8cecfe1 authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-4027: ensuring that an image exists before adding source variable in uwService

parent c06c9923
No related branches found
No related tags found
No related merge requests found
......@@ -101,13 +101,17 @@ class UWService implements UWServiceInterface {
// Get the image object from the node.
$image = $node->$field_name->entity;
// Get all the image variables, including the sources using the prepareResponsiveImage function.
$image_variables = $this->prepareResponsiveImage($image, 'uw_ris_media');
// Ensure that we have an image before adding variables.
if ($image !== NULL) {
// Set the responsive image variables for the teaser content.
$variables['sources'] = $image_variables['responsive_sources'];
$variables['img_element'] = $image_variables['img_element']['#uri'];
$variables['alt'] = $image->field_media_image->alt;
// Get all the image variables, including the sources using the prepareResponsiveImage function.
$image_variables = $this->prepareResponsiveImage($image, 'uw_ris_media');
// Set the responsive image variables for the teaser content.
$variables['sources'] = $image_variables['responsive_sources'];
$variables['img_element'] = $image_variables['img_element']['#uri'];
$variables['alt'] = $image->field_media_image->alt;
}
break;
case 'tags':
......
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