diff --git a/capsule-prototype/js/online-script.js b/capsule-prototype/js/online-script.js
index 7ec53495b0ca28e340dc057eb1af4e38ebfb6b23..6204a50e1d5e9035cae32843f71e803a80d0e30f 100644
--- a/capsule-prototype/js/online-script.js
+++ b/capsule-prototype/js/online-script.js
@@ -339,7 +339,10 @@ function setEditionControls() {
 	});
 
 	$("#paste_modal button.validate").click(function(event) {
-		var b64img = $("#paste_modal img")[0].src;
+		var img = $("#paste_modal img");
+		if (img.length < 1)
+			return;
+		var b64img = img[0].src;
 		var data = b64img.match(/data:([a-z]+)\/([a-z]+);base64,(.*)/);
 		var type = data[1], subtype = data[2], b64data = data[3];
 		var bin_str = atob(b64data);