diff --git a/src/Service/UWService.php b/src/Service/UWService.php
index a2798510224f81b72db43f1a6253188a8c5a8799..4b21eaae703efbe213b1d734a94555b0fbcefb6b 100644
--- a/src/Service/UWService.php
+++ b/src/Service/UWService.php
@@ -79,10 +79,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 6641302bc7a9a86fc2accdf3e0567d5d11cd1fd1..f299ed3c6df11abdf080cc546da69a82263c4ada 100644
--- a/src/Service/UWServiceInterface.php
+++ b/src/Service/UWServiceInterface.php
@@ -17,15 +17,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;
 
   /**
    * Gets content types that have feature images.