Created
July 20, 2018 13:57
-
-
Save dimsemenov/45475827294269d071d9425b032df759 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add to theme functions.php | |
// Removes lazy loading from the first image of the slider | |
function rs_disable_first_lazy_image($out) { | |
$url = preg_match('/<a class="rsImg" href="(.+)">(.+)<\/a>/', $out, $match); | |
if ( empty($match[1]) ) { | |
return $out; | |
} | |
$alt = ''; | |
if ( !empty($match[2]) ) { | |
$alt = esc_attr($match[2]); | |
} | |
$first_img_html = '<img class="rsImg" src="'. esc_attr($match[1]) .'" alt="'.$alt.'"/>'; | |
return preg_replace('/<a class="rsImg"(.+)<\/a>/', $first_img_html, $out, 1); | |
} | |
add_filter('new_rs_slides_output_before_end', 'rs_disable_first_lazy_image', 10, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment