diff --git a/file.php b/file.php
index 22cc8094be840bc25b322a6d571921f697beb8f8..fda45974ed942b2e342a9a1efc8c0eaa06ce99c1 100644
--- a/file.php
+++ b/file.php
@@ -29,11 +29,16 @@ if (!$_GET['key']
 // Validate session access hash - we want to make sure the link is FRESH!
 // and the user has access to the parent ticket!!
 if ($file->verifySignature($_GET['signature'], $_GET['expires'])) {
-    if (($s = @$_GET['s']) && strpos($file->getType(), 'image/') === 0)
-        return $file->display($s);
+    try {
+        if (($s = @$_GET['s']) && strpos($file->getType(), 'image/') === 0)
+            return $file->display($s);
 
-    // Download the file..
-    $file->download(@$_GET['disposition'] ?: false, $_GET['expires']);
+        // Download the file..
+        $file->download(@$_GET['disposition'] ?: false, $_GET['expires']);
+    }
+    catch (Exception $x) {
+        Http::response(500, 'Unable to find that file: '.$ex->getMessage());
+    }
 }
 // else
 Http::response(404, __('Unknown or invalid file'));
diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php
index 1bd831a38ee245e6b82adca315094aaf2c874b8f..fe5bfd04aced74215f6dd7e856288b5ee5ab877c 100644
--- a/include/staff/ticket-view.inc.php
+++ b/include/staff/ticket-view.inc.php
@@ -1010,5 +1010,5 @@ foreach (AttachmentFile::objects()->filter(array(
         'filename' => $file->name,
     );
 } ?>
-$.showImagesInline(<?php echo JsonDataEncoder::encode($urls); ?>);
+$('#ticket_thread').data('imageUrls', <?php echo JsonDataEncoder::encode($urls); ?>);
 </script>