diff --git a/core/js/jquery.ocdialog.js b/core/js/jquery.ocdialog.js
index e48e3e8df6ab8cafbb88b8afb4225cba68dba093..ea034f0aff7060428c81dba1b79fb397e7657889 100644
--- a/core/js/jquery.ocdialog.js
+++ b/core/js/jquery.ocdialog.js
@@ -78,8 +78,12 @@
 				var pos = self.parent.position();
 				self.$dialog.css({
 					left: pos.left + ($(window).innerWidth() - self.$dialog.outerWidth())/2,
-					top: pos.top + ($(window).innerHeight() - self.$dialog.outerHeight())/2
+					top: pos.top + ($(window).innerHeight() - self.$dialog.outerHeight())/2,
+					width: Math.min(self.options.width, $(window).innerWidth() - 20 ),
+					height: Math.min(self.options.height, $(window).innerHeight() - 20)
 				});
+				// set sizes of content
+				self._setSizes();
 			});
 
 			this._setOptions(this.options);
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index afd7debb6958fb85034867dda29b6e9fc33643ad..0692a9df5ca95f6fac00049a9d44e675d5783f80 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -207,7 +207,8 @@ var OCdialogs = {
 
 			self.$filePicker.ocdialog({
 				closeOnEscape: true,
-				width: (4/5)*$(document).width(),
+				// max-width of 600
+				width: Math.min((4/5)*$(document).width(), 600),
 				height: 420,
 				modal: modal,
 				buttons: buttonlist,