Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * We start out with $imgHTML_raw, instead of $imgHTML.
- */
- foreach ( $matches[0] as $imgHTML_raw ) {
- /*
- * Replace the current site URL with the network URL.
- */
- $imgHTML = str_replace( get_site_url(), network_site_url(), $imgHTML_raw );
- // don't to the replacement if a skip class is provided and the image has the class
- if ( ! ( is_array( $this->_skip_classes ) && preg_match( $skip_images_regex, $imgHTML_raw ) ) ) {
- // replace the src and add the data-src attribute
- $replaceHTML = preg_replace( '/<img(.*?)src=/i', '<img$1src="' . $this->_placeholder_url . '" data-lazy-type="image" data-lazy-src=', $imgHTML );
- // add the lazy class to the img element
- if ( preg_match( '/class="/i', $replaceHTML ) ) {
- $replaceHTML = preg_replace( '/class="(.*?)"/i', 'class="lazy lazy-hidden $1"', $replaceHTML );
- } else {
- $replaceHTML = preg_replace( '/<img/i', '<img class="lazy lazy-hidden"', $replaceHTML );
- }
- $replaceHTML .= '<noscript>' . $imgHTML_raw . '</noscript>';
- array_push( $search, $imgHTML_raw );
- array_push( $replace, $replaceHTML );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement