Last active
January 11, 2024 13:36
-
-
Save mksddn/a5954917a4d0b9850e9013a5673d2b8a to your computer and use it in GitHub Desktop.
WP Lazy load for images
This file contains hidden or 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
/** | |
* Добавление loading="lazy" к изображениям, добавленным через редактор | |
*/ | |
add_filter ('the_content', 'add_lazy_load_tag'); | |
function add_lazy_load_tag($content) { | |
return preg_replace('/img/', 'img loading="lazy"', $content); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment