diff --git a/src/Service/UWService.php b/src/Service/UWService.php
index 663a0025b99f1b0fd61d6187f693cd315bf9609b..de7600a29398ac52ab98570f5a3a35d5178898a0 100644
--- a/src/Service/UWService.php
+++ b/src/Service/UWService.php
@@ -81,31 +81,35 @@ class UWService implements UWServiceInterface {
    */
   public function prepareResponsiveImage(EntityInterface $entity, string $image_style): array {
 
-    // Load in the file object if we have one.
-    if ($file = $entity->field_media_image->entity) {
-
-      // Need to set these variables so that responsive image function,
-      // has all the necessary info to process the image style.
-      $variables['uri'] = $file->getFileUri();
-      $variables['responsive_image_style_id'] = $image_style;
-
-      // Set the alt for the image.
-      $variables['alt'] = $entity->field_media_image->alt;
-
-      // These is a function from the responsive image module that sets all
-      // the variables for the sources of the responsive image.
-      template_preprocess_responsive_image($variables);
-
-      // Step through each of the sources and setup our own sources array.
-      foreach ($variables['sources'] as $source) {
-        $variables['responsive_sources'][] = [
-          'srcset' => $source->storage()['srcset']->value(),
-          'media' => $source->storage()['media']->value(),
-          'type' => $source->storage()['type']->value(),
-        ];
-      }
+    // Ensure that we can load an entity on the media.
+    if (isset($entity->field_media_image->entity)) {
+
+      // Load in the file object if we have one.
+      if ($file = $entity->field_media_image->entity) {
+
+        // Need to set these variables so that responsive image function,
+        // has all the necessary info to process the image style.
+        $variables['uri'] = $file->getFileUri();
+        $variables['responsive_image_style_id'] = $image_style;
+
+        // Set the alt for the image.
+        $variables['alt'] = $entity->field_media_image->alt;
+
+        // These is a function from the responsive image module that sets all
+        // the variables for the sources of the responsive image.
+        template_preprocess_responsive_image($variables);
+
+        // Step through each of the sources and setup our own sources array.
+        foreach ($variables['sources'] as $source) {
+          $variables['responsive_sources'][] = [
+            'srcset' => $source->storage()['srcset']->value(),
+            'media' => $source->storage()['media']->value(),
+            'type' => $source->storage()['type']->value(),
+          ];
+        }
 
-      return $variables;
+        return $variables;
+      }
     }
 
     return [];