WordPress.org

Ready to get started?Download WordPress

Forums

jQuery Image Lazy Load WP
[resolved] jQuery Image Lazy Load WP disable for iphone (2 posts)

  1. DopinPanda
    Member
    Posted 3 years ago #

    anyone can help me at least disable the lazy load for iphone? cause all the images below the current view get grey.
    thanks. i've been reading and no one has an answer, so at least it would be great if someone can help me with jquery code to disable for iphone, and where to put it. thanks in advance

  2. DopinPanda
    Member
    Posted 3 years ago #

    OK!!
    this code worked for me, hope for u too.
    ------------------------------------------------------

    <?php
    
      /*
      Plugin Name: jQuery lazy load plugin
      Plugin URI: http://github.com/ayn/wp-jquery-lazy-load/
      Description: a quick and dirty wordpress plugin to enable image lazy loading.
      Version: v0.10
      Author: Andrew Ng
      Author URI: http://blog.andrewng.com
      */
    
    function jquery_lazy_load_headers() {
      $plugin_path = plugins_url('/', __FILE__);
      $lazy_url = $plugin_path . 'javascripts/jquery.lazyload.mini.js';
      $jq_url = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';
      wp_deregister_script('jquery');
      wp_enqueue_script('jquery', $jq_url, false, '1.4.2');
      wp_enqueue_script('jquerylazyload', $lazy_url, 'jquery', '1.5.0');
    }
    
    function jquery_lazy_load_ready() {
      $placeholdergif = plugins_url('images/grey.gif', __FILE__);
      echo <<<EOF
    <script type="text/javascript">
    jQuery(document).ready(function($){
      if (navigator.platform == "iPad") return;
    if (navigator.platform == "iPhone") return;
      jQuery("img").lazyload({
        effect:"fadeIn",
       threshold : 200,
        placeholder: "$placeholdergif"
      });
    });
    </script>
    EOF;
    }
    
      add_action('wp_head', 'jquery_lazy_load_headers', 5);
      add_action('wp_head', 'jquery_lazy_load_ready', 12);
    ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic