*Avatar: Calculate thumbnail dimensions based on devicePixelRatio
Multiply the dimension by the device pixel ratio and then round it to get the width/height of the thumbnail to use in the request.
This commit is contained in:
parent
3d507e9840
commit
39de37b547
2 changed files with 12 additions and 12 deletions
|
@ -22,8 +22,8 @@ module.exports = {
|
||||||
avatarUrlForMember: function(member, width, height, resizeMethod) {
|
avatarUrlForMember: function(member, width, height, resizeMethod) {
|
||||||
var url = member.getAvatarUrl(
|
var url = member.getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : width,
|
Math.floor(width * window.devicePixelRatio),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : height,
|
Math.floor(height * window.devicePixelRatio),
|
||||||
resizeMethod,
|
resizeMethod,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
|
@ -40,8 +40,8 @@ module.exports = {
|
||||||
avatarUrlForUser: function(user, width, height, resizeMethod) {
|
avatarUrlForUser: function(user, width, height, resizeMethod) {
|
||||||
var url = ContentRepo.getHttpUriForMxc(
|
var url = ContentRepo.getHttpUriForMxc(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(), user.avatarUrl,
|
MatrixClientPeg.get().getHomeserverUrl(), user.avatarUrl,
|
||||||
window.devicePixelRatio > 1.2 ? 96 : width,
|
Math.floor(width * window.devicePixelRatio),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : height,
|
Math.floor(height * window.devicePixelRatio),
|
||||||
resizeMethod
|
resizeMethod
|
||||||
);
|
);
|
||||||
if (!url || url.length === 0) {
|
if (!url || url.length === 0) {
|
||||||
|
|
|
@ -59,8 +59,8 @@ module.exports = React.createClass({
|
||||||
ContentRepo.getHttpUriForMxc(
|
ContentRepo.getHttpUriForMxc(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
props.oobData.avatarUrl,
|
props.oobData.avatarUrl,
|
||||||
window.devicePixelRatio > 1.2 ? 96 : props.width,
|
Math.floor(props.width * window.devicePixelRatio),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : props.height,
|
Math.floor(props.height * window.devicePixelRatio),
|
||||||
props.resizeMethod
|
props.resizeMethod
|
||||||
), // highest priority
|
), // highest priority
|
||||||
this.getRoomAvatarUrl(props),
|
this.getRoomAvatarUrl(props),
|
||||||
|
@ -76,8 +76,8 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
return props.room.getAvatarUrl(
|
return props.room.getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : props.width,
|
Math.floor(props.width * window.devicePixelRatio),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : props.height,
|
Math.floor(props.height * window.devicePixelRatio),
|
||||||
props.resizeMethod,
|
props.resizeMethod,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
@ -107,16 +107,16 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
return theOtherGuy.getAvatarUrl(
|
return theOtherGuy.getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : props.width,
|
Math.floor(props.width * window.devicePixelRatio),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : props.height,
|
Math.floor(props.height * window.devicePixelRatio),
|
||||||
props.resizeMethod,
|
props.resizeMethod,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
} else if (userIds.length == 1) {
|
} else if (userIds.length == 1) {
|
||||||
return mlist[userIds[0]].getAvatarUrl(
|
return mlist[userIds[0]].getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : props.width,
|
Math.floor(props.width * window.devicePixelRatio),
|
||||||
window.devicePixelRatio > 1.2 ? 96 : props.height,
|
Math.floor(props.height * window.devicePixelRatio),
|
||||||
props.resizeMethod,
|
props.resizeMethod,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue