Skip to content

Commit d76ff5a

Browse files
committed
* Add filter to a3 lazy load to add skip class no-lazyload
* Add filter to rocket_async_css_process_responsive_image to add no-lazyload class if we are processing a slider * Add filter to do_shortcode_tag to add no-lazyload to all class attributes in the slider
1 parent 5711cf8 commit d76ff5a

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

lib/Rocket/Async/CSS/Integration/RevolutionSlider.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public function init() {
2828
add_filter( 'rocket_async_css_lazy_load_responsive_image', [ $this, 'check_image' ], 10, 4 );
2929
add_action( 'revslider_modify_core_settings', [ $this, 'in_slider' ] );
3030
add_filter( 'revslider_add_js_delay', [ $this, 'out_slider' ], 10, 2 );
31+
add_filter( 'a3_lazy_load_skip_images_classes', [ $this, 'skip_class' ] );
32+
add_filter( 'rocket_async_css_process_responsive_image', [ $this, 'block_image' ] );
33+
add_filter( 'do_shortcode_tag', [ $this, 'post_process_shortcode' ], 10, 2 );
3134
}
3235
}
3336

@@ -75,4 +78,32 @@ public function out_slider( $value ) {
7578

7679
return $value;
7780
}
78-
}
81+
82+
public function skip_class( $classes ) {
83+
$classes = array_map( 'trim', explode( ',', $classes ) );
84+
$classes[] = 'no-lazyload';
85+
$classes = array_unique( array_filter( $classes ) );
86+
$classes = implode( ',', $classes );
87+
return $classes;
88+
}
89+
90+
public function block_image( $value ) {
91+
if ( $this->in_slider ) {
92+
if ( false === strpos( $value, 'no-lazyload' ) ) {
93+
$value = str_replace( 'class="', 'class="no-lazyload ', $value );
94+
$value = str_replace( "class='", "class='no-lazyload ", $value );
95+
}
96+
}
97+
return $value;
98+
}
99+
100+
public function post_process_shortcode( $value, $tag ) {
101+
if ( 'rev_slider' === $tag ) {
102+
if ( false === strpos( $value, 'no-lazyload' ) ) {
103+
$value = str_replace( 'class="', 'class="no-lazyload ', $value );
104+
$value = str_replace( "class='", "class='no-lazyload ", $value );
105+
}
106+
}
107+
return $value;
108+
}
109+
}

0 commit comments

Comments
 (0)