Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

Commit

Permalink
Set pictures' width and height.
Browse files Browse the repository at this point in the history
Set pictures model's width and height property,
and serve them to client.
  • Loading branch information
Hyeonje Alex Jun committed Nov 16, 2012
1 parent 8be76f5 commit a5fa24b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions server/classes.js
Expand Up @@ -98,10 +98,10 @@ module.exports = {
});
};

this.changePicture = function(pid) {
this.current_picture = pid;
this.changePicture = function(picture) {
this.current_picture = picture._id;
_.each(this.users, function(user) {
user.socket.emit('picture_changed', {pid: pid});
user.socket.emit('picture_changed', {pid: picture._id, width: picture.width, height: picture.height});
});
};
}
Expand Down
5 changes: 4 additions & 1 deletion server/handlers.js
Expand Up @@ -61,6 +61,9 @@ function Handlers(web) {
var createThumbnailAndMinified = function() {
// get size
gm(original).size(function(err, size) {
picture.width = size.width;
picture.height = size.height;

// create thumbnail
var thumbnail_width = size.width >= size.height ? 300 : size.width * 300 / size.height,
thumbnail_height = size.width <= size.height ? 300 : size.height * 300 / size.width,
Expand Down Expand Up @@ -93,7 +96,7 @@ function Handlers(web) {
}

// set as current picture of channel
web.socket.changePicture(channel, picture._id);
web.socket.changePicture(channel, picture);
});
};

Expand Down
4 changes: 2 additions & 2 deletions server/socket.js
Expand Up @@ -81,8 +81,8 @@ function Socket(web) {
});
});

this.changePicture = function(channel, pid) {
channels[channel].changePicture(pid);
this.changePicture = function(channel, picture) {
channels[channel].changePicture(picture);
};
}

Expand Down

0 comments on commit a5fa24b

Please sign in to comment.