diff --git a/code/template/helper/lazysizes.php b/code/template/helper/lazysizes.php index 71c349cf..bd985fa3 100644 --- a/code/template/helper/lazysizes.php +++ b/code/template/helper/lazysizes.php @@ -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); + } } });