Hey!! I think that custom elements should replace native images elements on content output, not on content input. Actually, the content is modified and saved to database. In this way you get stuck to PWP lazy image plugin. If you want to use other lazy load solution or want to change the theme at any point in the future, you will need to rewrite all the posts content and save them again to database.
Alternative: use the_conent filter instead of content_save_pre. This way you preserve the content in the native format and you are free to switch between themes, lazy load solutions or even publishing platforms at any time:
Hey!! I think that custom elements should replace native images elements on content output, not on content input. Actually, the content is modified and saved to database. In this way you get stuck to PWP lazy image plugin. If you want to use other lazy load solution or want to change the theme at any point in the future, you will need to rewrite all the posts content and save them again to database.
Alternative: use
the_conent
filter instead ofcontent_save_pre
. This way you preserve the content in the native format and you are free to switch between themes, lazy load solutions or even publishing platforms at any time:add_filter('the_content' , 'lazify_images', 0, 1);
It can add a very little extra work in every request, but you get more freedom. What do you think?