Round optimized img dimension to next 100px for better caching.

Doing double `Math.ceil()` just to make it easier to disable the 100px thing in the future.
This commit is contained in:
infinite-persistence 2022-04-01 09:04:12 +08:00 committed by Thomas Zarebczan
parent f175a765ae
commit 7ccaf06527

View file

@ -4,7 +4,9 @@ import { getImageProxyUrl, getThumbnailCdnUrl } from 'util/thumbnail';
function scaleToDevicePixelRatio(value: number) {
const devicePixelRatio = window.devicePixelRatio || 1.0;
return Math.ceil(value * devicePixelRatio);
const nextInteger = Math.ceil(value * devicePixelRatio);
// Round to next 100px for better caching
return Math.ceil(nextInteger / 100) * 100;
}
function getOptimizedImgUrl(url, width, height, quality) {