FIX: show retina avatars on Chrome (#11480)

chromium may report float device pixel ratio below 1.5 that is still clearly retina:

```
window.devicePixelRatio
1.4999998807907104
```

We used to round this down to 1 and not provide these browsers with retina avatars.

New algorithm is much more forgiving, anything over 1.1 gets 2x images, anything over 2.1 gets 3x images.
This commit is contained in:
Sam 2020-12-14 09:39:10 +11:00 committed by GitHub
parent ae114a6ee8
commit cfb81b7895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -59,7 +59,13 @@ export function avatarUrl(template, size) {
export function getRawSize(size) {
const pixelRatio = window.devicePixelRatio || 1;
return size * Math.min(3, Math.max(1, Math.round(pixelRatio)));
let rawSize = 1;
if (pixelRatio > 1.1 && pixelRatio < 2.1) {
rawSize = 2;
} else if (pixelRatio >= 2.1) {
rawSize = 3;
}
return size * rawSize;
}
export function avatarImg(options, customGetURL) {