diff --git a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
--- a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
+++ b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
@@ -197,7 +197,7 @@
       $alt = $options['alt'];
     }
 
-    if (!strlen($alt)) {
+    if (!phutil_nonempty_string($alt)) {
       $alt = $file->getAltText();
     }
 
@@ -346,9 +346,11 @@
   }
 
   private function parseDimension($string) {
-    $string = trim($string);
+    if (phutil_nonempty_string($string)) {
+      $string = trim($string);
+    }
 
-    if (preg_match('/^(?:\d*\\.)?\d+%?$/', $string)) {
+    if ($string && preg_match('/^(?:\d*\\.)?\d+%?$/', $string)) {
       return $string;
     }