From 06943daf57dd42ae16802cfe6a5489c8f1510acf Mon Sep 17 00:00:00 2001 From: Johan Janssens Date: Tue, 23 Nov 2021 16:53:57 +0100 Subject: [PATCH] #812 - Add missing check --- code/template/helper/lazysizes.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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); + } } });