Created
June 14, 2019 18:58
-
-
Save lukecav/510cc61ad34e3df2cac661e28a2a514c to your computer and use it in GitHub Desktop.
Native Lazy Load to oEmbed iFrames in WordPress
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
function lazy_embed_oembed_html($html, $url, $attr){ | |
$html = str_replace('<iframe ','<iframe loading="lazy" ',$html); | |
return $html; | |
} | |
add_filter('embed_oembed_html', 'lazy_embed_oembed_html',10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://plugins.svn.wordpress.org/native-lazy-oembed/trunk/native-lazy-oembed.php