PHP code example of wp-media / rocket-lazy-load

1. Go to this page and download the library: Download wp-media/rocket-lazy-load library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wp-media / rocket-lazy-load example snippets


add_action( 'wp', 'deactivate_rocket_lazyload_on_single' );
    function deactivate_rocket_lazyload_on_single() {
    if ( is_single() ) {
        add_filter( 'do_rocket_lazyload', '__return_false' );
    }
}

function rocket_lazyload_custom_threshold( $threshold ) {
    return 100;
}
add_filter( 'rocket_lazyload_threshold', 'rocket_lazyload_custom_threshold' );

function rocket_lazyload_custom_placeholder( $placeholder ) {
    return 'default.jpg';
}
add_filter( 'rocket_lazyload_placeholder', 'rocket_lazyload_custom_placeholder' );

function rocket_lazyload_exclude_youtube( $patterns ) {
    $patterns[] = 'string_to_match';

    return $patterns;
}
add_filter( 'rocket_lazyload_exclude_youtube_thumbnail', 'rocket_lazyload_exclude_youtube' );