Skip to content

Instantly share code, notes, and snippets.

@dimsemenov
Created July 20, 2018 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimsemenov/45475827294269d071d9425b032df759 to your computer and use it in GitHub Desktop.
Save dimsemenov/45475827294269d071d9425b032df759 to your computer and use it in GitHub Desktop.
// 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