Skip to content

Commit

Permalink
#812 - Add missing check
Browse files Browse the repository at this point in the history
  • Loading branch information
johanjanssens committed Nov 23, 2021
1 parent f478172 commit 06943da
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions code/template/helper/lazysizes.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ public function import($plugin = '', $config = array())
window.addEventListener('lazybeforesizes', function (e)
{
//If 2g or saveData load lower quality image
if(navigator.connection.saveData === true) {
e.detail.width = Math.round(e.detail.width / 3);
//If 2g or saveData load lower quality image
} else if(navigator.connection.effectiveType.includes('2g')) {
e.detail.width = Math.round(e.detail.width / 2);
if ('connection' in navigator)
{
//If 2g or saveData load lower quality image
if(navigator.connection.saveData === true) {
e.detail.width = Math.round(e.detail.width / 3);
//If 2g or saveData load lower quality image
} else if(navigator.connection.effectiveType.includes('2g')) {
e.detail.width = Math.round(e.detail.width / 2);
}
}
});
Expand Down

0 comments on commit 06943da

Please sign in to comment.