diff --git a/lib/models/Courseware/BlockTypes/Text.php b/lib/models/Courseware/BlockTypes/Text.php
index c4fe67c68db239f9a3c8ce1d82265201686aaf53..7edeebc9262e359fb6c77acefbea5587010bdee7 100755
--- a/lib/models/Courseware/BlockTypes/Text.php
+++ b/lib/models/Courseware/BlockTypes/Text.php
@@ -100,7 +100,9 @@ class Text extends BlockType
                 $file = $this->extractFile($element->getAttribute('src'));
                 if ($file !== null) {
                     $file_copy_id = $this->copyFileById($file->id, $rangeId);
-                    $element->setAttribute('src', \FileRef::find($file_copy_id)->getDownloadURL());
+                    if ($file_copy_id) {
+                        $element->setAttribute('src', \FileRef::find($file_copy_id)->getDownloadURL());
+                    }
                 }
             }
             $payload['text'] = $document->saveHTML();