Doesn't work in text widget
GermanKiwi opened this issue · comments
The description on this page states that the loading attribute should be added to "images in text widget content".
I have a text widget on my site which contains HTML, including an <img>
tag, and the loading attribute is not added to it. Not sure if that's currently expected behaviour?
Seems to be working well here. This runs on the widget_text_content
filter defined here: https://core.trac.wordpress.org/browser/tags/5.3.2/src/wp-includes/widgets/class-wp-widget-text.php#L280. It is conditional on $is_visual_text_widget
that distinguish between the "new" text+HTML widget content and the "old" text-only content (although these might have been HTML in the old content). It is (afaik) for back-compat for the text widget.
Perhaps try adding another instance of the widget and test again.
Thanks for the extra info! I've taken a closer look, and it turns out that my text widgets were the old text-only widgets, rather than the newer text+HTML widgets. (The newer text+HTML widgets have the "Visual" and "Text" tabs and a small, simple toolbar). I think I never replaced the old widgets with the new text+HTML widgets on my site when they were introduced to WordPress, as the old text-only widgets also worked fine with HTML being pasted into them.
Anyway, what I can now confirm is that the Lazy Loading plugin does work on:
- the newer text+HTML widget (when it contains an IMG tag)
- the Image widget (which obviously contains an IMG tag)
...but it does not work on:
- the old text-only widget (which still exists if users haven't replaced it with the newer widget)
- the "Custom HTML" widget (when it contains an IMG tag)
I suppose there's little point in making the plugin work on the old text-only widget, given that it's not used anymore, but I wonder if you should consider making the plugin work on the Custom HTML widget?
Additionally, it might be helpful to mention on this page – in the bullet-list of tags where the plugin works – that it also works on the Image widget too. :)