• Resolved Jack

    (@jack1132132)


    Hello,

    Is there any hook to disable image lazy load on specific pages? When I turn on lazy load it turns on in Safari too which causes the image to glitch .

    I’m thinking I could use a hook to detect if the user is on iOS using the function is_ios() and disable lazy load.

    So far I’ve found the filter w3tc_lazyload_on_initialized_javascript, could I use this filter for this purpose?

    thank you

    • This topic was modified 1 year, 9 months ago by Jack.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Jack

    (@jack1132132)

    Hello,

    So I found the hook w3tc_lazyload_can_process which does this, but I came to the conclusion that if the page is cached then especially the lazy load always needs to be off since if the cahced page was loaded from Chrome then that lazyload will always be there independent of which browser loads the cached page.

    So since in my case I have the cache for logged out users only, here’s my solution:

    function disable_lazy_loading_on_safari( $can_process ) {
    
    	$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
    
    	$browser_name = '';
    
    	if(strpos($HTTP_USER_AGENT, 'MSIE') !== false)
    		$browser_name = 'Internet explorer';
    	elseif(strpos($HTTP_USER_AGENT, 'Trident') !== false)
    		$browser_name = 'Internet explorer';
    	elseif(strpos($HTTP_USER_AGENT, 'Firefox') !== false)
    		$browser_name = 'Mozilla Firefox';
    	elseif(strpos($HTTP_USER_AGENT, 'Chrome') !== false)
    		$browser_name = 'Google Chrome';
    	elseif(strpos($HTTP_USER_AGENT, 'Opera Mini') !== false)
    		$browser_name = "Opera Mini";
    	elseif(strpos($HTTP_USER_AGENT, 'Opera') !== false)
    		$browser_name = "Opera";
    	elseif(strpos($HTTP_USER_AGENT, 'Safari') !== false)
    		$browser_name = "Safari";
    	else
    		$browser_name = 'Other';
    
        if ( !is_user_logged_in() || $browser_name === 'Safari' || $browser_name == 'Internet explorer') {
    
    		$can_process['enabled'] = false;
        }
    
        return $can_process;
    }
    add_filter( 'w3tc_lazyload_can_process', 'disable_lazy_loading_on_safari' );

    Thank you.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @jack1132132

    Thank you for reaching out and I am happy to help.

    I’ve checked numerous websites with Lazyload enabled on Safari, and there were no issues. If the issue is on the specific website, the question is if the theme is using some native lazyload or some slider, which may conflict with W3TC lazyload and the Safari native Lazyload.

    Just to confirm, you have managed to solve the problem with the filter you mentioned?

    Thanks!

    Thread Starter Jack

    (@jack1132132)

    Hello,

    This glitch was present when I used the regular lazyload attribute too, so I assumed W3 was doing the same thing. The images disappear and reappear if I lock and unlock the phone.

    Yes, the filter solved it. As now lazy load isn’t applied on safari

    thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Lazy load is used on iOS safari where it causes issues’ is closed to new replies.