diff --git a/addons/web_editor/static/src/js/widgets/widgets.js b/addons/web_editor/static/src/js/widgets/widgets.js index f8626e33390..8214754cd6b 100644 --- a/addons/web_editor/static/src/js/widgets/widgets.js +++ b/addons/web_editor/static/src/js/widgets/widgets.js @@ -229,7 +229,6 @@ var ImageDialog = Widget.extend({ this.push(attachment); this.$('input.url').val(''); this.search(); - this.images = []; }, form_submit: function (event) { var self = this; @@ -342,24 +341,20 @@ var ImageDialog = Widget.extend({ }, select_existing: function (e) { var $img = $(e.currentTarget); - if (!this.options.select_images) { - this.$('.o_existing_attachment_cell.o_selected').removeClass("o_selected"); - $img.closest('.o_existing_attachment_cell').addClass('o_selected'); - } else { - $img.closest('.o_existing_attachment_cell').toggleClass('o_selected'); - } var attachment = _.find(this.records, function (record) { return record.id === $img.data('id'); }); this.push(attachment); this.selected_existing(); }, selected_existing: function () { var self = this; + this.$('.o_existing_attachment_cell.o_selected').removeClass("o_selected"); var $select = this.$('.o_existing_attachment_cell [data-src]').filter(function () { var $img = $(this); return !!_.find(self.images, function (v) { return (v.url === $img.data("src") || ($img.data("url") && v.url === $img.data("url")) || v.id === $img.data("id")); }); }); + $select.closest('.o_existing_attachment_cell').addClass("o_selected"); return $select; }, try_remove: function (e) {