GoogleChromeLabs / wp-native-lazyload

WordPress plugin to lazy-load media using the native browser feature.
https://wordpress.org/plugins/native-lazyload/
Apache License 2.0
51 stars 13 forks source link

Adding fallback url filter for more customization #19

Open khuyennguyen7007 opened 4 years ago

khuyennguyen7007 commented 4 years ago

Issue Overview

I hope in next version, fallback url filter will be added for more customization. Eg: custom or moving the script to another directory.

Steps to Reproduce

In class Lazy_Load_Script::get_fallback_script_url(), we can change the method body to something like that:

protected function get_fallback_script_url() : string {
    $path = static::FALLBACK_SCRIPT_PATH;
    if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
        $path = str_replace( '/js/', '/js/src/', static::FALLBACK_SCRIPT_PATH );
    }
    $path = apply_filters('native_lazyload_fallback_script_path', $path);
    return apply_filters('native_lazyload_fallback_script_url', $this->context->url( $path ));;
}