Page MenuHomePhabricator

Allow extensions to implement void elements like img
Open, Needs TriagePublicFeature


I've been relying on the usability of the img tag for quite some time but just found out that wgAllowImageTag is now deprecated. Fortunately, the summary that came with the deprecation commit says

it could be reimplemented as an extension tag once it is removed from core

and elsewhere

register an extension tag named <img> instead.

While I'm glad it has not been removed yet, I hoped I could be ahead of trouble by doing just that, trying to add support by way of an extension. My first attempt involved using setHook() and I soon learned about Sanitizer::removeSomeTags(). But then I ran into a known issue, which is that certain void elements like img are not accepted by the parser. The Sanitizer method that checks wgAllowImageTag allows for a restricted list of void elements (see 'htmlsingle', 'htmlsingleonly') but does not accept additions. This also means that the method to be used by callers, removeSomeTags(), does not currently allow for a solution.

I'm not asking you to restore wgAllowImageTag or offer something like it in core functionality. My proposed solution would be to at least provide a way for extensions to implement void elements like img.

Event Timeline

Bugreporter subscribed.

We already have one void element (<references />), and Parsoid has special treatment for it.

Thanks but isn't that a slightly different use case? <img> and other HTML5 elements don't use self-closing tags with a trailing slash.

The void tags (br, link, img, etc.) are allowed to have a trailing slash as an artifact of living HTML having to deal with the remnants of XHTML. So that isn't a particularly large issue.