Skip to content

Commit

Permalink
use compressed images for cellular networks in dms
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Sep 12, 2023
1 parent daf4e7e commit 22218b1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion layouts/header/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down

0 comments on commit 22218b1

Please sign in to comment.