diff --git a/client/src/views/fields/attachment-multiple.js b/client/src/views/fields/attachment-multiple.js
index c8c24b68f7..7a36e10f86 100644
--- a/client/src/views/fields/attachment-multiple.js
+++ b/client/src/views/fields/attachment-multiple.js
@@ -186,6 +186,12 @@ Espo.define('views/fields/attachment-multiple', 'views/fields/base', function (D
this.listenTo(this.model, 'change:' + this.nameHashName, function () {
this.nameHash = _.clone(this.model.get(this.nameHashName)) || {};
}.bind(this));
+
+ this.once('remove', function () {
+ if (this.resizeIsBeingListened) {
+ $(window).off('resize.' + this.cid);
+ }
+ }.bind(this));
},
setupSearch: function () {
@@ -202,6 +208,11 @@ Espo.define('views/fields/attachment-multiple', 'views/fields/base', function (D
this.$attachments.empty();
},
+ handleResize: function () {
+ var width = this.$el.width();
+ this.$el.find('img.image-preview').css('maxWidth', width + 'px');
+ },
+
deleteAttachment: function (id) {
this.removeId(id);
if (this.model.isNew()) {
@@ -466,6 +477,16 @@ Espo.define('views/fields/attachment-multiple', 'views/fields/base', function (D
var type = this.$el.find('select.search-type').val();
this.handleSearchType(type);
}
+
+ if (this.mode === 'detail') {
+ if (this.previewSize === 'large') {
+ this.handleResize();
+ this.resizeIsBeingListened = true;
+ $(window).on('resize.' + this.cid, function () {
+ this.handleResize();
+ }.bind(this));
+ }
+ }
},
isTypeIsImage: function (type) {
@@ -483,7 +504,7 @@ Espo.define('views/fields/attachment-multiple', 'views/fields/base', function (D
var preview = name;
if (this.isTypeIsImage(type)) {
- preview = '
';
+ preview = '
';
}
return preview;
},
diff --git a/client/src/views/fields/file.js b/client/src/views/fields/file.js
index 6a7b9a0c3b..16e155924e 100644
--- a/client/src/views/fields/file.js
+++ b/client/src/views/fields/file.js
@@ -183,6 +183,11 @@ Espo.define('views/fields/file', 'views/fields/link', function (Dep) {
this.acceptAttribue = this.accept.join('|');
}
+ this.once('remove', function () {
+ if (this.resizeIsBeingListened) {
+ $(window).off('resize.' + this.cid);
+ }
+ }.bind(this));
},
afterRender: function () {
@@ -221,6 +226,21 @@ Espo.define('views/fields/file', 'views/fields/link', function (Dep) {
var type = this.$el.find('select.search-type').val();
this.handleSearchType(type);
}
+
+ if (this.mode === 'detail') {
+ if (this.previewSize === 'large') {
+ this.handleResize();
+ this.resizeIsBeingListened = true;
+ $(window).on('resize.' + this.cid, function () {
+ this.handleResize();
+ }.bind(this));
+ }
+ }
+ },
+
+ handleResize: function () {
+ var width = this.$el.width();
+ this.$el.find('img.image-preview').css('maxWidth', width + 'px');
},
getDetailPreview: function (name, type, id) {
@@ -231,7 +251,7 @@ Espo.define('views/fields/file', 'views/fields/link', function (Dep) {
case 'image/png':
case 'image/jpeg':
case 'image/gif':
- preview = '
';
+ preview = '
';
}
return preview;
},