Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWP Lazy Image plugin: Filter content on output, not on input #17

Open
CybMeta opened this issue Jan 30, 2018 · 2 comments
Open

PWP Lazy Image plugin: Filter content on output, not on input #17

CybMeta opened this issue Jan 30, 2018 · 2 comments

Comments

@CybMeta
Copy link

CybMeta commented Jan 30, 2018

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:

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?

@surma
Copy link
Contributor

surma commented Jan 30, 2018

I think that was mostly me not really knowing what I was doing and fiddling until it worked :D Happy to accept PRs to improve this.

@CybMeta
Copy link
Author

CybMeta commented Jan 30, 2018

Ok, I will try to fill a pull request. Thank you!!

@CybMeta CybMeta changed the title PWP Lazy Image plugin: Add custom elements to content on output, not on save PWP Lazy Image plugin: Filter content on output, not on input Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@surma @CybMeta and others