From 22218b1cdab84994f6c5a3dd542252684dc0ccb6 Mon Sep 17 00:00:00 2001 From: dimden Date: Tue, 12 Sep 2023 21:28:38 +0300 Subject: [PATCH] use compressed images for cellular networks in dms --- layouts/header/script.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/layouts/header/script.js b/layouts/header/script.js index 7940a9bb..c28fcd15 100644 --- a/layouts/header/script.js +++ b/layouts/header/script.js @@ -885,12 +885,15 @@ let userDataFunction = async user => { if(attachment.photo) { let photo = attachment.photo; let photoElement = document.createElement('img'); - photoElement.src = photo.media_url_https; + photoElement.src = photo.media_url_https + (window.navigator && navigator.connection && navigator.connection.type === 'cellular' && !vars.disableDataSaver ? ':small' : ''); photoElement.classList.add('message-element-media'); let [w, h] = calculateSize(photo.original_info.width, photo.original_info.height, 400, 500); photoElement.width = w; photoElement.height = h; photoElement.addEventListener('click', e => { + if(e.target.src.includes(':small')) { + e.target.src = e.target.src.replace(':small', ''); + }; new Viewer(photoElement, { transition: false });