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

Ensure compatibility with plugins that replace WP's default WYSIWYG editor #160

Closed
tevko opened this issue Aug 27, 2015 · 12 comments
Closed
Labels

Comments

@tevko
Copy link
Member

tevko commented Aug 27, 2015

In some cases, users can run into a bug when using a wysiwyg editor that is not the default tinyMCE editor provided by wordpress. This is most likely due to a javascript error, in that our plugin javascript isn't triggered by non-default wysiwyg editors. Here's an example of such - https://wordpress.org/support/topic/srcset-not-updating-when-image-is-replaced-in-black-studio-tinymce-widget-editor?replies=1

@tevko tevko added the bug label Aug 27, 2015
@joemcgill
Copy link
Member

This issue will become moot if we switch to content filtering (re: #144).

@joemcgill
Copy link
Member

Any external editor that applies filters attached to the_content filter hook should now automatically have srcset and sizes attributes added to images.

See #177

@marcochiesi
Copy link

Would you consider adding the filter also to the widget_text hook? It is used by the native WP text widget and also by other plugins like Black Studio TinyMCE Widget, which was mentioned at the beginning of this thread.

@joemcgill
Copy link
Member

Hi @marcochiesi. Thanks for the suggestion, it's definitely worth considering. I'm curious why you don't use the filters associated with the_content rather than the widget_text filters in your plugin, since you're including a full TinyMCE editor and not just a textarea input like the default text widget?

@marcochiesi
Copy link

The the_content filter is used to filter the content of posts, but when you use a widget there's no post associated with it. Often plugins that hook to the_content assume that there's a current post and they use post-related stuff, which is not relevant in a widget context (i.e. global $post variable or other functions to accessa data of the current post).
Moreover, the plugin is a replacement for the native WordPress text widget, which uses the widget_text filter, so every 3rd party script made for the native text widget will work out of the box.

@joemcgill
Copy link
Member

Got it. It would make sense that some filters would assume a global $post object. To be honest, I'm not sure if we should add this filter to text_widget by default or not, since most text widgets don't include a UI for embedding images directly.

Additionally, if this functionality gets merged into WordPress—which is the current goal—it would be better for you to apply the filter in the context of the plugin, rather than having WordPress automatically run all text widgets through this particular filter, in my opinion.

@joemcgill joemcgill reopened this Sep 23, 2015
@tevko
Copy link
Member Author

tevko commented Sep 23, 2015

@joemcgill as @marcochiesi mentioned, could cause some issues if a user is uploading images through a plugin like ACF?

@joemcgill
Copy link
Member

I don't think it would cause problems, but there might definitely be edge cases where filtering all text_widget content would be undesirable.

@marcochiesi
Copy link

If the code will get merged into WordPress core, I would definitely add the filter on the Black Studio TinyMCE Widget side. I suppose that the function name will change once it gets merged... isn't it?

@joemcgill
Copy link
Member

I suppose that the function name will change once it gets merged.

That's correct. I'll update you once we finalize the new filter name.

@joemcgill joemcgill added question and removed bug labels Oct 1, 2015
@joemcgill
Copy link
Member

Leaving this open until we finalize the new filter name. Changing status from bug to question.

@joemcgill
Copy link
Member

Hi @marcochiesi,

Looks like the core display filter is going to be named wp_make_content_images_responsive(). You can now test this on a development version of WordPress: https://github.com/wordpress/wordpress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants