diff --git a/src/Service/UWService.php b/src/Service/UWService.php
index e3d5f586780fbc83c85ad27ee81a4fe51ad8d527..810f9356542b600940838486be2350fb5fc00851 100644
--- a/src/Service/UWService.php
+++ b/src/Service/UWService.php
@@ -109,10 +109,10 @@ class UWService implements UWServiceInterface {
   /**
    * {@inheritDoc}
    */
-  public function prepareResponsiveImage(EntityInterface $entity, string $image_style): array {
+  public function prepareResponsiveImage(?EntityInterface $entity, string $image_style): array {
 
     // Ensure that we can load an entity on the media.
-    if (isset($entity->field_media_image->entity)) {
+    if ($entity && isset($entity->field_media_image->entity)) {
 
       // Load in the file object if we have one.
       if ($file = $entity->field_media_image->entity) {
diff --git a/src/Service/UWServiceInterface.php b/src/Service/UWServiceInterface.php
index 209b3577b949ebb835344946199e1f38c6a5dcdb..3cb259aca8e9260cb64ce080125ae10ac2e5d9a1 100644
--- a/src/Service/UWServiceInterface.php
+++ b/src/Service/UWServiceInterface.php
@@ -30,15 +30,15 @@ interface UWServiceInterface {
   /**
    * Prepares responsive image.
    *
-   * @param \Drupal\Core\Entity\EntityInterface $entity
-   *   Image entity.
+   * @param \Drupal\Core\Entity\EntityInterface|null $entity
+   *   Image entity or null.
    * @param string $image_style
    *   Image style to be used for responsive image.
    *
    * @return array
    *   Array with details for responsive image.
    */
-  public function prepareResponsiveImage(EntityInterface $entity, string $image_style): array;
+  public function prepareResponsiveImage(?EntityInterface $entity, string $image_style): array;
 
   /**
    * Get the UW images styles used in UW responsive image.