Created
September 7, 2014 08:08
-
-
Save solymosi/a57c5411a4fdb888b683 to your computer and use it in GitHub Desktop.
Advanced lazy load + Wordpress SEO output buffering fix
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
<? // just for syntax highlighting | |
add_action( 'template_redirect', 'lz_ob_start' ); | |
add_action( 'wp_footer', 'lz_rewrite' ); | |
function lz_rewrite() | |
{ | |
$buffer = ob_get_contents(); | |
ob_end_clean(); | |
$pattern = '/((?:\<img).*)(src)/'; | |
$plugin_dir_path = plugin_dir_url(__FILE__); | |
$buffer = preg_replace($pattern, "$1 src='" . $plugin_dir_path . "shade.gif' ImageHolder", $buffer); | |
echo $buffer; | |
return true; | |
} | |
function lz_ob_start() | |
{ | |
ob_start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment