diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index 8044128cbe7..2fc2861c0d2 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -175,7 +175,6 @@ openerp.mail = function(session) {
} else {
this.$render_compact.hide();
}
-
this.bind_events();
},
@@ -198,7 +197,6 @@ openerp.mail = function(session) {
/* when a user click on the upload button, send file read on_attachment_loaded
*/
on_attachment_change: function (event) {
- console.log('attach');
event.stopPropagation();
var self = this;
var $target = $(event.target);
@@ -347,7 +345,6 @@ openerp.mail = function(session) {
/*post a message and fetch the message*/
on_message_post: function (body) {
- console.log('post');
var self = this;
if (! body) {
@@ -639,18 +636,35 @@ openerp.mail = function(session) {
}
for (var l in this.attachment_ids) {
var attach = this.attachment_ids[l];
+ if((attach.filename || attach.name).match(/[.](jpg|jpg|gif|png|tif|svg)$/i)) {
+ attach.is_image = true;
+
+ }
attach['url'] = mail.ChatterUtils.get_attachment_url(this.session, attach);
}
+
},
start: function() {
this._super.apply(this, arguments);
this.expender();
this.$el.hide().fadeIn(750);
+ this.resize_img();
this.bind_events();
this.create_thread();
},
+ resize_img: function() {
+ this.$("img").load(function() {
+ var h = $(this).height();
+ var w = $(this).width();
+ if( h > 100 || w >100 ) {
+ var ratio = 100 / (h > w ? h : w);
+ $(this).attr("width", parseInt( w*ratio )).attr("height", parseInt( h*ratio ));
+ }
+ });
+ },
+
/**
* Bind events in the widget. Each event is slightly described
* in the function. */
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index 3cd43996569..1e3c699e39a 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -70,8 +70,8 @@
Template used to display attachments in a mail.message
-->
-
-
+
+
@@ -79,15 +79,24 @@
-
-
-
+
+
+
+
+
[
-
+
+
+
+
+
+
+
+